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 CxEditor : DevExpress.XtraEditors.XtraForm { public CxTxViewModel info; private List infos; public CxEditor() { InitializeComponent(); this.layoutControl1.UseDefault(); this.Text = "添加测向站"; info = new CxTxViewModel(); this.StartPosition = FormStartPosition.CenterParent; } public CxEditor(CxTxViewModel info) : this() { this.Text = "编辑测向站"; this.info = info; } private async void CxEditor_Load(object sender, EventArgs e) { if (this.Text == "编辑测向站" && info != null) { this.txtCxTxName.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(); var unitOfWork = IocContainer.UnitOfWork; var repsCx = unitOfWork.Of(); var res = await repsCx.FindAsync(f=>f.TxType== EnumTxType.Cx); infos.AddRange(res.To>()); } private void btnOk_Click(object sender, EventArgs e) { try { if (infos.Any(i => i.Id != info.Id && i.Name == txtCxTxName.Text)) { DxHelper.MsgBoxHelper.ShowError($"测向站[{txtCxTxName.Text}]已经存在!"); return; } info.Name= txtCxTxName.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; } } }