SigEditor.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 SigEditor : DevExpress.XtraEditors.XtraForm
  20. {
  21. public SigInfo info;
  22. public SigEditor()
  23. {
  24. InitializeComponent();
  25. this.layoutControl1.UseDefault();
  26. this.Text = "添加信号";
  27. info = new SigInfo();
  28. this.StartPosition = FormStartPosition.CenterParent;
  29. }
  30. public SigEditor(SigInfo info)
  31. : this()
  32. {
  33. this.Text = "编辑信号";
  34. this.info = info;
  35. }
  36. private void SatEditor_Load(object sender, EventArgs e)
  37. {
  38. txtSigType.Properties.Items.Clear();
  39. txtSigType.Properties.Items.AddEnum<EnumSigCheckType>();
  40. if (this.Text == "编辑信号" && info != null)
  41. {
  42. this.txtFreqUp.EditValue = info.FreqUp;
  43. this.txtFreqDown.EditValue = info.FreqDown;
  44. this.txtSnr.EditValue = info.Snr;
  45. //List<EnumSigCheckType> deWay = new List<EnumSigCheckType>();
  46. //if (info.SigType.HasFlag(EnumSigCheckType.DAMA))
  47. //{
  48. // deWay.Add(EnumSigCheckType.DAMA);
  49. //}
  50. //if (info.SigType.HasFlag(EnumSigCheckType.IBS))
  51. //{
  52. // deWay.Add(EnumSigCheckType.IBS);
  53. //}
  54. //if (info.SigType.HasFlag(EnumSigCheckType.Ky5758))
  55. //{
  56. // deWay.Add(EnumSigCheckType.Ky5758);
  57. //}
  58. //this.txtSigType.EditValue = string.Join(",", deWay);
  59. this.txtSigType.EditValue = info.SigType.ToString();
  60. }
  61. }
  62. private void btnCancel_Click(object sender, EventArgs e)
  63. {
  64. this.DialogResult = DialogResult.Cancel;
  65. }
  66. private void btnOk_Click(object sender, EventArgs e)
  67. {
  68. try
  69. {
  70. if (txtFreqUp.EditValue == null)
  71. {
  72. dxErrorProvider.SetError(txtFreqUp, "请输入上行频点");
  73. return;
  74. }
  75. if (txtFreqDown.EditValue == null)
  76. {
  77. dxErrorProvider.SetError(txtFreqDown, "请输入下行频点");
  78. return;
  79. }
  80. if (string.IsNullOrEmpty(txtSigType.EditValue.ToString()))
  81. {
  82. dxErrorProvider.SetError(txtSigType, "请选择信号类型");
  83. return;
  84. }
  85. if (txtSnr.EditValue == null)
  86. {
  87. dxErrorProvider.SetError(txtSnr, "请输入门限");
  88. return;
  89. }
  90. info.FreqUp = Convert.ToDouble(txtFreqUp.EditValue);
  91. info.FreqDown = Convert.ToDouble(txtFreqDown.EditValue);
  92. info.Snr = Convert.ToDouble(txtSnr.EditValue);
  93. var res = txtSigType.EditValue.ToString().Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries).ToList();
  94. if (res.Count() == 2)
  95. {
  96. info.SigType = (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[0]) | (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[1]);
  97. }
  98. else if (res.Count() == 3)
  99. {
  100. info.SigType = (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[0]) | (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[1]) | (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[2]);
  101. }
  102. else
  103. {
  104. info.SigType = (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[0]);
  105. }
  106. this.DialogResult = DialogResult.OK;
  107. }
  108. catch (Exception ex)
  109. {
  110. Serilog.Log.Error(ex, "编辑信号信息出错");
  111. DxHelper.MsgBoxHelper.ShowError("编辑信号信息出错");
  112. }
  113. }
  114. }
  115. }