123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- 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.Repostory;
- using XdCxRhDW.Repostory.EFContext;
- using XdCxRhDW.Repostory.Model;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class SatEditor : DevExpress.XtraEditors.XtraForm
- {
- public SatInfo info;
- public SatEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.Text = "添加卫星";
- info = new SatInfo();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public SatEditor(SatInfo info)
- : this()
- {
- this.Text = "编辑卫星";
- this.info = info;
- }
- private async void SatEditor_Load(object sender, EventArgs e)
- {
- var listXl = await XlCache.GetAllAsync();
- this.searchLookUpEdit1.UseDefault().SetData(listXl,nameof(XlInfo.Sat)).UseDoubleClickToSelectAll();
- if (this.Text == "编辑卫星" && info != null)
- {
- this.txtSatName.Text = info.SatName;
- this.txtSatLon.Text = info.SatLon?.ToString();
- this.txtSatTrans.Text=info.SatTrans?.ToString();
- this.searchLookUpEdit1.EditValue = info.Sat;
- }
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- private void btnOk_Click(object sender, EventArgs e)
- {
- try
- {
- var sat = searchLookUpEdit1.Text;
- var idx = sat.LastIndexOf('(');
- var satCodeStr = sat.Substring(idx + 1, sat.Length - idx - 2);
- info.SatCode = Convert.ToInt32(satCodeStr);
- info.SatName = txtSatName.Text.Trim();
- if (!string.IsNullOrWhiteSpace(txtSatTrans.Text))
- info.SatTrans = Convert.ToDouble(txtSatTrans.Text);
- if (!string.IsNullOrWhiteSpace(txtSatLon.Text))
- info.SatLon = Convert.ToDouble(txtSatLon.Text);
- this.DialogResult = DialogResult.OK;
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, "编辑卫星信息出错");
- DxHelper.MsgBoxHelper.ShowError("编辑卫星信息出错");
- }
- }
- }
- }
|