123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using centralController.model;
- using DevComponents.DotNetBar;
- using DevComponents.DotNetBar.Controls;
- using Terminal;
- namespace centralController
- {
- public partial class FormPaymentScheme : DevComponents.DotNetBar.OfficeForm
- {
- public FormPaymentScheme()
- {
- InitializeComponent();
- }
- private void Form_paymentScheme_Load(object sender, EventArgs e)
- {
- if (PaymentScheme.ins == null)
- {
- PaymentScheme.ins = PaymentScheme.GetCurrentPaymentScheme(1);
- MessageBox.Show("无法获得收费策略,请稍后重试", "警告");
- Close();
- }
- else
- {
- displayScheme();
- SetReadOnly(true);
- }
- }
- /// <summary>
- /// 显示计费策略
- /// </summary>
- private void displayScheme()
- {
- cb_schemeSwitch.SelectedIndex = PaymentScheme.ins.schemeType - 1;
- tbx_freeTime.Text = PaymentScheme.ins.freeTime.ToString();
- tbx_firstChargeTime.Text = PaymentScheme.ins.firstChargeTime.ToString();
- tbx_firstCharge.Text = PaymentScheme.ins.firstCharge.ToString();
- tbx_intervalCharge.Text = PaymentScheme.ins.intervalCharge.ToString();
- tbx_upperBound.Text = PaymentScheme.ins.upperBound.ToString();
- tbx_eachCharge.Text = PaymentScheme.ins.eachCharge.ToString();
- tbx_overnightCharge.Text = PaymentScheme.ins.overnightCharge.ToString();
- tbx_startChargeTime.Text = PaymentScheme.ins.startChargeTime;
- tbx_endChargeTime.Text = PaymentScheme.ins.endChargeTime;
- tbx_peakCharge.Text = PaymentScheme.ins.chargeStandard.ToString();
- tbx_monthCard.Text = PaymentScheme.ins.monthCardCharge.ToString();
- tbx_seasonCard.Text = PaymentScheme.ins.seasonCardCharge.ToString();
- tbx_halfYearCard.Text = PaymentScheme.ins.halfYearCardCharge.ToString();
- tbx_yearCard.Text = PaymentScheme.ins.yearCardCharge.ToString();
- tbx_bookCharge.Text = PaymentScheme.ins.bookCharge.ToString();
- }
- /// <summary>
- /// 设置textboxX只读属性
- /// </summary>
- /// <param name="isReadOnly"></param>
- private void SetReadOnly(bool isReadOnly)
- {
- try
- {
- Control.ControlCollection gp_paymentCC = gp_paymentScheme.Controls;
- for (int i = 0; i < gp_paymentCC.Count; i++)
- {
- if (gp_paymentCC[i].GetType().Equals(typeof(TextBoxX)))
- {
- ((TextBoxX)gp_paymentCC[i]).ReadOnly = isReadOnly;
- }
- }
- }
- catch (Exception ex) { Console.WriteLine("启动修改按钮异常,panel1"); }
- try
- {
- Control.ControlCollection gp_vipCC = gp_VIPScheme.Controls;
- for (int i = 0; i < gp_vipCC.Count; i++)
- {
- if (gp_vipCC[i].GetType().Equals(typeof(TextBoxX)))
- {
- ((TextBoxX)gp_vipCC[i]).ReadOnly = isReadOnly;
- }
- }
- }
- catch (Exception ex) { Console.WriteLine("启动修改按钮异常,panel2"); }
- cb_schemeSwitch.Enabled = !isReadOnly;
- }
- /// <summary>
- /// 允许修改计费策略参数
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnx_enableModify_Click(object sender, EventArgs e)
- {
- SetReadOnly(false);
- }
- /// <summary>
- /// 将修改结果写入数据库
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnx_confirmModification_Click(object sender, EventArgs e)
- {
- try
- {
- PaymentScheme ps = new PaymentScheme()
- {
- schemeType = cb_schemeSwitch.SelectedIndex + 1,
- freeTime = int.Parse(tbx_freeTime.Text),
- firstChargeTime = int.Parse(tbx_firstChargeTime.Text),
- firstCharge = int.Parse(tbx_firstCharge.Text),
- intervalCharge = int.Parse(tbx_intervalCharge.Text),
- upperBound = int.Parse(tbx_upperBound.Text),
- eachCharge = int.Parse(tbx_eachCharge.Text),
- overnightCharge = int.Parse(tbx_overnightCharge.Text),
- startChargeTime = tbx_startChargeTime.Text,
- endChargeTime = tbx_endChargeTime.Text,
- chargeStandard = int.Parse(tbx_peakCharge.Text),
- monthCardCharge = int.Parse(tbx_monthCard.Text),
- seasonCardCharge = int.Parse(tbx_seasonCard.Text),
- halfYearCardCharge = int.Parse(tbx_halfYearCard.Text),
- yearCardCharge = int.Parse(tbx_yearCard.Text),
- bookCharge = int.Parse(tbx_bookCharge.Text),
- };
- bool result = PaymentScheme.SetPaymentScheme(ps);
- if (result)
- {
- PaymentScheme.ins = PaymentScheme.GetCurrentPaymentScheme(1);
- displayScheme();
- SetReadOnly(true);
- MessageBox.Show("成功更新收费策略", "提示");
- }
- else
- {
- MessageBox.Show("收费策略修改失败,请检查后重试", "提示");
- }
- }
- catch (Exception ex) { MessageBox.Show("收费策略修改失败,请检查后重试", "提示"); }
- }
- /// <summary>
- /// 取消修改,显示原参数并将参数设为只读
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnx_cancelModify_Click(object sender, EventArgs e)
- {
- displayScheme();
- SetReadOnly(true);
- }
- }
- }
|