12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- 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 CdbTxInfo info;
- private List<CdbTxInfo> infos;
- public CdbEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加超短波";
- info = new CdbTxInfo();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public CdbEditor(CdbTxInfo 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.txtAlt.Text = info.Alt.ToString();
- this.txtRemark.EditValue = info.Remark;
- }
- infos = new List<CdbTxInfo>();
- var unitOfWork = IocContainer.UnitOfWork;
- var repsCdb = unitOfWork.Of<CdbTxInfo>();
- 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);
- //if (!string.IsNullOrWhiteSpace(txtAlt.Text))
- info.Alt = Convert.ToDouble(txtAlt.Text);
- info.Remark = txtRemark.Text;
- 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;
- }
- }
- }
|