| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using DevExpress.XtraEditors;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.Entity;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.Remoting.Metadata.W3cXsd2001;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Documents;
- using System.Windows.Forms;
- using XdCxRhDW.Entity;
- using XdCxRhDW.Repostory;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class CDBSatEditor : DevExpress.XtraEditors.XtraForm
- {
- public CDBSatInfo info;
- private List<CDBSatInfo> infos;
- public CDBSatEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加超短波卫星";
- info = new CDBSatInfo();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public CDBSatEditor(CDBSatInfo info)
- : this()
- {
- this.Text = "编辑超短波卫星";
- this.info = info;
- }
- private async void SatEditor_Load(object sender, EventArgs e)
- {
- infos = new List<CDBSatInfo>();
- using (RHDWContext db = new RHDWContext())
- {
- var res = await db.CDBSatInfos.ToListAsync();
- infos.AddRange(res);
- }
- if (this.Text == "编辑超短波卫星" && info != null)
- {
- this.txtSatName.Text = info.SatName;
- this.txtSatCode.EditValue = info.SatCode;
- }
-
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- private void btnOk_Click(object sender, EventArgs e)
- {
- try
- {
- var satCode = Convert.ToInt32(txtSatCode.Text);
- if (infos.Any(i => i.ID != info.ID && i.SatCode == satCode))
- {
- DxHelper.MsgBoxHelper.ShowError($"超短波卫星[{satCode}]已经存在!");
- return;
- }
- info.SatCode = satCode;
- info.SatName = txtSatName.Text.Trim();
- this.DialogResult = DialogResult.OK;
- }
- catch (Exception ex)
- {
- XdCxRhDW.Framework.LogHelper.Error( "编辑超短波卫星信息出错", ex);
- DxHelper.MsgBoxHelper.ShowError("编辑超短波卫星信息出错");
- }
- }
- }
- }
|