AntEditor.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.Windows.Forms;
  11. using DataSimulation.Repostory;
  12. using DataSimulation.Repostory.EFContext;
  13. using DataSimulation.Repostory.Model;
  14. namespace DataSimulation.Forms.EditForms
  15. {
  16. public partial class AntEditor : DevExpress.XtraEditors.XtraForm
  17. {
  18. public AntInfo info;
  19. public AntEditor()
  20. {
  21. InitializeComponent();
  22. this.layoutControl1.UseDefault();
  23. this.Text = "添加天线";
  24. info = new AntInfo();
  25. this.StartPosition = FormStartPosition.CenterParent;
  26. }
  27. public AntEditor(AntInfo info)
  28. : this()
  29. {
  30. this.Text = "编辑天线";
  31. this.info = info;
  32. }
  33. private void AntEditor_Load(object sender, EventArgs e)
  34. {
  35. if (this.Text == "编辑天线" && info != null)
  36. {
  37. this.txtAntName.Text = info.AntName;
  38. this.txtAntLon.Text = $"{info.AntLon}";
  39. this.txtAntLat.Text = $"{info.AntLat}";
  40. }
  41. }
  42. private void btnCancel_Click(object sender, EventArgs e)
  43. {
  44. this.DialogResult = DialogResult.Cancel;
  45. }
  46. private void btnOk_Click(object sender, EventArgs e)
  47. {
  48. try
  49. {
  50. info.AntName = txtAntName.Text.Trim();
  51. info.AntLon = Convert.ToDouble(txtAntLon.Text);
  52. info.AntLat = Convert.ToDouble(txtAntLat.Text);
  53. this.DialogResult = DialogResult.OK;
  54. }
  55. catch (Exception ex)
  56. {
  57. Serilog.Log.Error(ex, $"{this.Text}信息出错");
  58. DxHelper.MsgBoxHelper.ShowError($"{this.Text}信息出错");
  59. }
  60. }
  61. }
  62. }