123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using DevExpress.Utils.About;
- using DW5S.Entity;
- using DW5S.Repostory;
- using DW5S.Service;
- using DW5S.ViewModel;
- using ExtensionsDev;
- using Serilog;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace DW5S.App.EditForms
- {
- public partial class RefEditor : DevExpress.XtraEditors.XtraForm
- {
-
-
- public RefTxViewModel info;
- private List<RefTxViewModel> infos;
- public RefEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加参考站";
- info = new RefTxViewModel();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public RefEditor(RefTxViewModel info)
- : this()
- {
- this.Text = "编辑参考站";
- this.info = info;
- }
- private async void RefEditor_Load(object sender, EventArgs e)
- {
- if (this.Text == "编辑参考站" && info != null)
- {
- this.txtRefTxName.Text = info.Name;
- this.txtLon.Text = info.Lon.ToString();
- this.txtLat.Text = info.Lat.ToString();
- this.txtRemark.EditValue = info.Remark;
- this.checkEdit.EditValue = info.Enable;
- }
- infos = new List<RefTxViewModel>();
- var unitOfWork = IocContainer.UnitOfWork;
- var repsRef = unitOfWork.Of<TxInfo>();
- var res = await repsRef.FindAsync(f=>f.TxType== EnumTxType.Ref);
- infos.AddRange(res.To<List<RefTxViewModel>>());
- }
- private void btnOk_Click(object sender, EventArgs e)
- {
- try
- {
- if (infos.Any(i => i.Id != info.Id && i.Name == txtRefTxName.Text))
- {
- DxHelper.MsgBoxHelper.ShowError($"参考站[{txtRefTxName.Text}]已经存在!");
- return;
- }
- info.Name= txtRefTxName.Text;
- info.Lon=Convert.ToDouble(txtLon.Text);
- info.Lat = Convert.ToDouble(txtLat.Text);
- info.Remark = txtRemark.Text;
- info.Enable = (bool)checkEdit.EditValue;
- this.DialogResult = DialogResult.OK;
- }
- catch (Exception ex)
- {
- string msg = "编辑参考站信息出错";
- IocContainer.Logger.Error(ex, msg);
- DxHelper.MsgBoxHelper.ShowError(msg);
- }
- }
- private void btnCancle_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- }
- }
|