SatEditor.cs 2.4 KB

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