1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using DevExpress.Xpo.DB;
- using DW5S.Entity;
- using DW5S.Repostory;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows.Forms;
- using XdCxRhDW5S.ViewModel;
- namespace DW5S.App.UserControl
- {
- public partial class CDBSatEditor : DevExpress.XtraEditors.XtraForm
- {
- public SatViewModel info;
- public CDBSatEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加地面站卫星";
- info = new SatViewModel();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public CDBSatEditor(SatViewModel info)
- : this()
- {
- this.Text = "编辑地面站卫星";
- this.info = info;
- }
- private void SatEditor_Load(object sender, EventArgs e)
- {
- 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 async void btnOk_Click(object sender, EventArgs e)
- {
- try
- {
- var unitOfWork = IocContainer.UnitOfWork;
- var repsSat =await unitOfWork.Of<SatInfo>().FindAsync(s=>s.EnumSatType== EnumSatType.CdbSat);
- var satCode = Convert.ToInt32(txtSatCode.Text);
- bool existed = repsSat.Any(p => p.Id != info.Id && p.SatCode == satCode);
- if (existed)
- {
- DxHelper.MsgBoxHelper.ShowError($"地面站卫星[{satCode}]已经存在!");
- return;
- }
- info.SatCode = satCode;
- info.SatName = txtSatName.Text.Trim();
- info.EnumSatType = EnumSatType.CdbSat;
- this.DialogResult = DialogResult.OK;
- }
- catch (Exception ex)
- {
- IocContainer.Logger.Error( "编辑地面站卫星信息出错", ex);
- DxHelper.MsgBoxHelper.ShowError("编辑地面站卫星信息出错");
- }
- }
- }
- }
|