SatEditor.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using DevExpress.XtraEditors;
  2. using ExtensionsDev;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Data.Entity;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Documents;
  14. using System.Windows.Forms;
  15. using XdCxRhDW.Repostory;
  16. using XdCxRhDW.Repostory.EFContext;
  17. using XdCxRhDW.Repostory.Model;
  18. namespace XdCxRhDW.App.EditForms
  19. {
  20. public partial class SatEditor : DevExpress.XtraEditors.XtraForm
  21. {
  22. public SatInfo info;
  23. public SatEditor()
  24. {
  25. InitializeComponent();
  26. this.layoutControl1.UseDefault();
  27. this.Text = "添加卫星";
  28. info = new SatInfo();
  29. this.StartPosition = FormStartPosition.CenterParent;
  30. }
  31. public SatEditor(SatInfo info)
  32. : this()
  33. {
  34. this.Text = "编辑卫星";
  35. this.info = info;
  36. }
  37. private async void SatEditor_Load(object sender, EventArgs e)
  38. {
  39. var listXl = await XlCache.GetAllAsync();
  40. this.searchLookUpEdit1.UseDefault().SetData(listXl,nameof(XlInfo.Sat)).UseDoubleClickToSelectAll();
  41. if (this.Text == "编辑卫星" && info != null)
  42. {
  43. this.txtSatName.Text = info.SatName;
  44. this.txtSatLon.Text = info.SatLon?.ToString();
  45. this.txtSatTrans.Text=info.SatTrans?.ToString();
  46. this.searchLookUpEdit1.EditValue = info.Sat;
  47. }
  48. }
  49. private void btnCancel_Click(object sender, EventArgs e)
  50. {
  51. this.DialogResult = DialogResult.Cancel;
  52. }
  53. private void btnOk_Click(object sender, EventArgs e)
  54. {
  55. try
  56. {
  57. var sat = searchLookUpEdit1.Text;
  58. var idx = sat.LastIndexOf('(');
  59. var satCodeStr = sat.Substring(idx + 1, sat.Length - idx - 2);
  60. info.SatCode = Convert.ToInt32(satCodeStr);
  61. info.SatName = txtSatName.Text.Trim();
  62. if (!string.IsNullOrWhiteSpace(txtSatTrans.Text))
  63. info.SatTrans = Convert.ToDouble(txtSatTrans.Text);
  64. if (!string.IsNullOrWhiteSpace(txtSatLon.Text))
  65. info.SatLon = Convert.ToDouble(txtSatLon.Text);
  66. this.DialogResult = DialogResult.OK;
  67. }
  68. catch (Exception ex)
  69. {
  70. Serilog.Log.Error(ex, "编辑卫星信息出错");
  71. DxHelper.MsgBoxHelper.ShowError("编辑卫星信息出错");
  72. }
  73. }
  74. }
  75. }