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 RecEditor : DevExpress.XtraEditors.XtraForm
- {
-
-
- public RecTxInfo info;
- private List<RecTxInfo> infos;
- public RecEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加接收站";
- info = new RecTxInfo();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public RecEditor(RecTxInfo info)
- : this()
- {
- this.Text = "编辑接收站";
- this.info = info;
- }
- private async void RecEditor_Load(object sender, EventArgs e)
- {
- if (this.Text == "编辑接收站" && info != null)
- {
- this.txtRecTxName.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<RecTxInfo>();
- var unitOfWork = IocContainer.UnitOfWork;
- var repsRec = unitOfWork.Of<RecTxInfo>();
- var res = await repsRec.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 == txtRecTxName.Text))
- {
- DxHelper.MsgBoxHelper.ShowError($"接收站[{txtRecTxName.Text}]已经存在!");
- return;
- }
- info.Name = txtRecTxName.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;
- }
- }
- }
|