12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- 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.EFContext;
- using XdCxRhDW.Repostory.Model;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class SatEditor : DevExpress.XtraEditors.XtraForm
- {
- public SatInfo info;
- public SatEditor()
- {
- InitializeComponent();
- 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)
- {
- List<string> list = new List<string>();
- using (RHDWContext db = new RHDWContext())
- {
- var res = await db.XlInfos.OrderBy(p => p.SatName).ToListAsync();
- if (res != null)
- list.AddRange(res.Select(p=>p.Sat));
- }
- this.searchLookUpEdit1.UseDefault().SetStringData(list).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("编辑卫星信息出错");
- }
- }
- }
- }
|