1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 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().SetStringData(listXl.Select(p=>p.Sat)).UseDoubleClickToSelectAll();
- if (this.Text == "编辑卫星" && info != null)
- {
- this.txtSatName.Text = info.SatName;
- this.txtSatLon.Text = info.SatLon.ToString();
- }
- }
- 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(txtSatLon.Text))
- info.SatLon = Convert.ToDouble(txtSatLon.Text);
- this.DialogResult = DialogResult.OK;
- }
- catch (Exception ex)
- {
- Serilog.Log.Error(ex, "编辑卫星信息出错");
- DxHelper.MsgBoxHelper.ShowError("编辑卫星信息出错");
- }
- }
- }
- }
|