FormPaymentScheme.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using centralController.model;
  9. using DevComponents.DotNetBar;
  10. using DevComponents.DotNetBar.Controls;
  11. using Terminal;
  12. namespace centralController
  13. {
  14. public partial class FormPaymentScheme : DevComponents.DotNetBar.OfficeForm
  15. {
  16. public FormPaymentScheme()
  17. {
  18. InitializeComponent();
  19. }
  20. private void Form_paymentScheme_Load(object sender, EventArgs e)
  21. {
  22. if (PaymentScheme.ins == null)
  23. {
  24. PaymentScheme.ins = PaymentScheme.GetCurrentPaymentScheme(1);
  25. MessageBox.Show("无法获得收费策略,请稍后重试", "警告");
  26. Close();
  27. }
  28. else
  29. {
  30. displayScheme();
  31. SetReadOnly(true);
  32. }
  33. }
  34. /// <summary>
  35. /// 显示计费策略
  36. /// </summary>
  37. private void displayScheme()
  38. {
  39. cb_schemeSwitch.SelectedIndex = PaymentScheme.ins.schemeType - 1;
  40. tbx_freeTime.Text = PaymentScheme.ins.freeTime.ToString();
  41. tbx_firstChargeTime.Text = PaymentScheme.ins.firstChargeTime.ToString();
  42. tbx_firstCharge.Text = PaymentScheme.ins.firstCharge.ToString();
  43. tbx_intervalCharge.Text = PaymentScheme.ins.intervalCharge.ToString();
  44. tbx_upperBound.Text = PaymentScheme.ins.upperBound.ToString();
  45. tbx_eachCharge.Text = PaymentScheme.ins.eachCharge.ToString();
  46. tbx_overnightCharge.Text = PaymentScheme.ins.overnightCharge.ToString();
  47. tbx_startChargeTime.Text = PaymentScheme.ins.startChargeTime;
  48. tbx_endChargeTime.Text = PaymentScheme.ins.endChargeTime;
  49. tbx_peakCharge.Text = PaymentScheme.ins.chargeStandard.ToString();
  50. tbx_monthCard.Text = PaymentScheme.ins.monthCardCharge.ToString();
  51. tbx_seasonCard.Text = PaymentScheme.ins.seasonCardCharge.ToString();
  52. tbx_halfYearCard.Text = PaymentScheme.ins.halfYearCardCharge.ToString();
  53. tbx_yearCard.Text = PaymentScheme.ins.yearCardCharge.ToString();
  54. tbx_bookCharge.Text = PaymentScheme.ins.bookCharge.ToString();
  55. }
  56. /// <summary>
  57. /// 设置textboxX只读属性
  58. /// </summary>
  59. /// <param name="isReadOnly"></param>
  60. private void SetReadOnly(bool isReadOnly)
  61. {
  62. try
  63. {
  64. Control.ControlCollection gp_paymentCC = gp_paymentScheme.Controls;
  65. for (int i = 0; i < gp_paymentCC.Count; i++)
  66. {
  67. if (gp_paymentCC[i].GetType().Equals(typeof(TextBoxX)))
  68. {
  69. ((TextBoxX)gp_paymentCC[i]).ReadOnly = isReadOnly;
  70. }
  71. }
  72. }
  73. catch (Exception ex) { Console.WriteLine("启动修改按钮异常,panel1"); }
  74. try
  75. {
  76. Control.ControlCollection gp_vipCC = gp_VIPScheme.Controls;
  77. for (int i = 0; i < gp_vipCC.Count; i++)
  78. {
  79. if (gp_vipCC[i].GetType().Equals(typeof(TextBoxX)))
  80. {
  81. ((TextBoxX)gp_vipCC[i]).ReadOnly = isReadOnly;
  82. }
  83. }
  84. }
  85. catch (Exception ex) { Console.WriteLine("启动修改按钮异常,panel2"); }
  86. cb_schemeSwitch.Enabled = !isReadOnly;
  87. }
  88. /// <summary>
  89. /// 允许修改计费策略参数
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void btnx_enableModify_Click(object sender, EventArgs e)
  94. {
  95. SetReadOnly(false);
  96. }
  97. /// <summary>
  98. /// 将修改结果写入数据库
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. private void btnx_confirmModification_Click(object sender, EventArgs e)
  103. {
  104. try
  105. {
  106. PaymentScheme ps = new PaymentScheme()
  107. {
  108. schemeType = cb_schemeSwitch.SelectedIndex + 1,
  109. freeTime = int.Parse(tbx_freeTime.Text),
  110. firstChargeTime = int.Parse(tbx_firstChargeTime.Text),
  111. firstCharge = int.Parse(tbx_firstCharge.Text),
  112. intervalCharge = int.Parse(tbx_intervalCharge.Text),
  113. upperBound = int.Parse(tbx_upperBound.Text),
  114. eachCharge = int.Parse(tbx_eachCharge.Text),
  115. overnightCharge = int.Parse(tbx_overnightCharge.Text),
  116. startChargeTime = tbx_startChargeTime.Text,
  117. endChargeTime = tbx_endChargeTime.Text,
  118. chargeStandard = int.Parse(tbx_peakCharge.Text),
  119. monthCardCharge = int.Parse(tbx_monthCard.Text),
  120. seasonCardCharge = int.Parse(tbx_seasonCard.Text),
  121. halfYearCardCharge = int.Parse(tbx_halfYearCard.Text),
  122. yearCardCharge = int.Parse(tbx_yearCard.Text),
  123. bookCharge = int.Parse(tbx_bookCharge.Text),
  124. };
  125. bool result = PaymentScheme.SetPaymentScheme(ps);
  126. if (result)
  127. {
  128. PaymentScheme.ins = PaymentScheme.GetCurrentPaymentScheme(1);
  129. displayScheme();
  130. SetReadOnly(true);
  131. MessageBox.Show("成功更新收费策略", "提示");
  132. }
  133. else
  134. {
  135. MessageBox.Show("收费策略修改失败,请检查后重试", "提示");
  136. }
  137. }
  138. catch (Exception ex) { MessageBox.Show("收费策略修改失败,请检查后重试", "提示"); }
  139. }
  140. /// <summary>
  141. /// 取消修改,显示原参数并将参数设为只读
  142. /// </summary>
  143. /// <param name="sender"></param>
  144. /// <param name="e"></param>
  145. private void btnx_cancelModify_Click(object sender, EventArgs e)
  146. {
  147. displayScheme();
  148. SetReadOnly(true);
  149. }
  150. }
  151. }