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 RefEditor : DevExpress.XtraEditors.XtraForm
- {
-
-
- public RefTxInfo info;
- private List<RefTxInfo> infos;
- public RefEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加参考站";
- info = new RefTxInfo();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public RefEditor(RefTxInfo 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.txtAlt.Text = info.Alt.ToString();
- this.txtRemark.EditValue = info.Remark;
- }
- infos = new List<RefTxInfo>();
- var unitOfWork = IocContainer.UnitOfWork;
- var repsRef = unitOfWork.Of<RefTxInfo>();
- var res = await repsRef.GetAllAsync();
- infos.AddRange(res);
- }
- 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.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;
- }
- }
- }
|