SatEditor.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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().SetStringData(listXl.Select(p=>p.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. }
  47. }
  48. private void btnCancel_Click(object sender, EventArgs e)
  49. {
  50. this.DialogResult = DialogResult.Cancel;
  51. }
  52. private void btnOk_Click(object sender, EventArgs e)
  53. {
  54. try
  55. {
  56. var sat = searchLookUpEdit1.Text;
  57. var idx = sat.LastIndexOf('(');
  58. var satCodeStr = sat.Substring(idx + 1, sat.Length - idx - 2);
  59. info.SatCode = Convert.ToInt32(satCodeStr);
  60. info.SatName = txtSatName.Text.Trim();
  61. if (!string.IsNullOrWhiteSpace(txtSatTrans.Text))
  62. info.SatTrans = Convert.ToDouble(txtSatTrans.Text);
  63. if (!string.IsNullOrWhiteSpace(txtSatLon.Text))
  64. info.SatLon = Convert.ToDouble(txtSatLon.Text);
  65. this.DialogResult = DialogResult.OK;
  66. }
  67. catch (Exception ex)
  68. {
  69. Serilog.Log.Error(ex, "编辑卫星信息出错");
  70. DxHelper.MsgBoxHelper.ShowError("编辑卫星信息出错");
  71. }
  72. }
  73. }
  74. }