123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using DevExpress.Utils.About;
- using DW5S.Entity;
- using DW5S.Repostory;
- using DW5S.Service;
- using ExtensionsDev;
- using Newtonsoft.Json;
- 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 TxInfo info;
- private List<TxInfo> infos;
- public RecEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加接收站";
- info = new TxInfo();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public RecEditor(RecTxViewModel info)
- : this()
- {
- this.Text = "编辑接收站";
- this.info = info.To<TxInfo>();
- }
- 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.txtRemark.EditValue = info.Remark;
- }
- infos = new List<TxInfo>();
- var unitOfWork = IocContainer.UnitOfWork;
- var repsRec = unitOfWork.Of<TxInfo>();
- var res = await repsRec.FindAsync(f => f.TxType == EnumTxType.Rec, 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);
- info.Remark = txtRemark.Text;
- info.TxType = EnumTxType.Rec;
- 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;
- }
- }
- }
|