12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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.Windows.Forms;
- using DataSimulation.Repostory;
- using DataSimulation.Repostory.EFContext;
- using DataSimulation.Repostory.Model;
- namespace DataSimulation.Forms.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("编辑卫星信息出错");
- }
- }
- }
- }
|