1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using DevExpress.Utils.About;
- using DW5S.Entity;
- using DW5S.Repostory;
- using DW5S.Service;
- 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 CdbEditor : DevExpress.XtraEditors.XtraForm
- {
-
-
- public TxInfo info;
- private List<TxInfo> infos;
- public CdbEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加超短波";
- info = new TxInfo();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public CdbEditor(TxInfo info)
- : this()
- {
- this.Text = "编辑超短波";
- this.info = info;
- }
- private async void CdbEditor_Load(object sender, EventArgs e)
- {
- if (this.Text == "编辑超短波" && info != null)
- {
- this.txtCdbTxName.Text = info.Name;
- this.txtLon.Text = info.Lon.ToString();
- this.txtLat.Text = info.Lat.ToString();
- this.txtRemark.EditValue = info.Remark;
- }
- infos = new List<TxInfo>();
- var unitOfWork = IocContainer.UnitOfWork;
- var repsCdb = unitOfWork.Of<TxInfo>();
- var res = await repsCdb.GetAllAsync(p => p.Name);
- infos.AddRange(res);
- }
- private void btnOk_Click(object sender, EventArgs e)
- {
- try
- {
- if (infos.Any(i => i.Id != info.Id && i.Name == txtCdbTxName.Text))
- {
- DxHelper.MsgBoxHelper.ShowError($"超短波[{txtCdbTxName.Text}]已经存在!");
- return;
- }
- info.Name= txtCdbTxName.Text;
- info.Lon=Convert.ToDouble(txtLon.Text);
- info.Lat = Convert.ToDouble(txtLat.Text);
- info.Remark = txtRemark.Text;
- info.TxType = EnumTxType.Cdb;
- 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;
- }
- }
- }
|