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.Entity;
  16. using XdCxRhDW.Repostory;
  17. namespace XdCxRhDW.App.EditForms
  18. {
  19. public partial class SatEditor : DevExpress.XtraEditors.XtraForm
  20. {
  21. public SatInfo info;
  22. public SatEditor()
  23. {
  24. InitializeComponent();
  25. this.layoutControl1.UseDefault();
  26. this.Text = "添加卫星";
  27. info = new SatInfo();
  28. this.StartPosition = FormStartPosition.CenterParent;
  29. }
  30. public SatEditor(SatInfo info)
  31. : this()
  32. {
  33. this.Text = "编辑卫星";
  34. this.info = info;
  35. }
  36. private async void SatEditor_Load(object sender, EventArgs e)
  37. {
  38. var listXl = await XlRepository.GetAllAsync();
  39. this.searchLookUpEdit1.UseDefault().SetData(listXl,nameof(XlInfo.Sat)).UseDoubleClickToSelectAll();
  40. if (this.Text == "编辑卫星" && info != null)
  41. {
  42. this.txtSatName.Text = info.SatName;
  43. this.txtSatLon.Text = info.SatLon?.ToString();
  44. this.txtSatTrans.Text=info.SatTrans?.ToString();
  45. this.searchLookUpEdit1.EditValue = info.Sat;
  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 = Math.Round(Convert.ToDouble(txtSatTrans.Text), 3);
  63. if (!string.IsNullOrWhiteSpace(txtSatLon.Text))
  64. info.SatLon = Math.Round(Convert.ToDouble(txtSatLon.Text), 1);
  65. this.DialogResult = DialogResult.OK;
  66. }
  67. catch (Exception ex)
  68. {
  69. Serilog.Log.Error(ex, "编辑卫星信息出错");
  70. DxHelper.MsgBoxHelper.ShowError("编辑卫星信息出错");
  71. }
  72. }
  73. }
  74. }