123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using PTMedicalInsurance.Variables;
- namespace PTMedicalInsurance.Forms
- {
- public partial class SettlementInfoIP : Form
- {
- public decimal hisSumAmt { get; set; }
- public decimal hisPreAmt { get; set; }
- public decimal acctPayAmt { get; set; }
- public decimal insuAmt { get; set; }
- public decimal cashpayAmt { get; set; }
- public SettlementInfoIP(string hisAmt,string hisPreAmt)
- {
- InitializeComponent();
- this.StartPosition = FormStartPosition.CenterParent;
- edt_HisSumAmt.Text = hisAmt;
- edt_PreAmt.Text = hisPreAmt;
- }
- public void SettleMentAmt()
- {
- if (IsMoney(edt_AcctPayAmt.Text) == false)
- {
- MessageBox.Show("请重新输入正确的医保个人账户支付金额");
- return;
- }
- if (IsMoney(edt_InsuAmt.Text) == false)
- {
- MessageBox.Show("请重新输入正确的医保基金支付金额");
- return;
- }
- hisSumAmt = decimal.Parse(edt_HisSumAmt.Text);
- hisPreAmt = decimal.Parse(edt_PreAmt.Text);
- acctPayAmt = decimal.Parse(edt_AcctPayAmt.Text);
- insuAmt = decimal.Parse(edt_InsuAmt.Text);
- edt_cashPayAmt.Text = (Math.Abs(hisSumAmt) - Math.Abs(hisPreAmt) - Math.Abs(acctPayAmt) - Math.Abs(insuAmt)).ToString();
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- if (IsMoney(edt_AcctPayAmt.Text) == false)
- {
- MessageBox.Show("请重新输入正确的医保个人账户支付金额");
- return;
- }
- if (IsMoney(edt_InsuAmt.Text) == false)
- {
- MessageBox.Show("请重新输入正确的医保基金支付金额");
- return;
- }
- if (double.Parse(edt_HisSumAmt.Text) <= 0)
- {
- MessageBox.Show("该患者住院费用总额异常,请检查!");
- return;
- }
-
- hisSumAmt = decimal.Parse(edt_HisSumAmt.Text);
- hisPreAmt = decimal.Parse(edt_PreAmt.Text);
- acctPayAmt = decimal.Parse(edt_AcctPayAmt.Text);
- insuAmt = decimal.Parse(edt_InsuAmt.Text);
- //cashpayAmt = double.Parse(edt_cashPayAmt.Text);
- cashpayAmt = Math.Abs(hisSumAmt) - Math.Abs(hisPreAmt) - Math.Abs(acctPayAmt) - Math.Abs(insuAmt);
- if (cashpayAmt < 0)
- {
- MessageBox.Show("【HIS总金额" + hisSumAmt.ToString() + "】-【预交金额" + hisPreAmt.ToString() + "】-【医保基金支付金额" + insuAmt.ToString() + "】-【医保个人账户支付金额" + acctPayAmt.ToString() + "】= 【现金支付金额" + cashpayAmt.ToString() + "】,现金支付金额小于0,请检查!");
- return;
- }
-
- this.DialogResult = DialogResult.OK;
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- public static bool IsMoney(string input)
- {
- string pattern = @"^\-{0,1}[0-9]{0,}\.{0,1}[0-9]{1,}$";
- return System.Text.RegularExpressions.Regex.IsMatch(input, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
- }
- private void edt_InsuAmt_KeyPress11(object sender, KeyPressEventArgs e)
- {
- //允许输入数字、小数点、删除键和负号
- if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.') && e.KeyChar != (char)('-'))
- {
- MessageBox.Show("请输入正确的数字");
- this.edt_InsuAmt.Text = "0.00";
- e.Handled = true;
- }
- if (e.KeyChar == (char)('-'))
- {
- if (edt_InsuAmt.Text != "")
- {
- MessageBox.Show("请输入正确的数字");
- this.edt_InsuAmt.Text = "0.00";
- e.Handled = true;
- }
- }
- //小数点只能输入一次
- if (e.KeyChar == (char)('.') && ((TextBox)sender).Text.IndexOf('.') != -1)
- {
- MessageBox.Show("请输入正确的数字");
- this.edt_InsuAmt.Text = "0.00";
- e.Handled = true;
- }
- //第一位不能为小数点
- if (e.KeyChar == (char)('.') && ((TextBox)sender).Text == "")
- {
- MessageBox.Show("请输入正确的数字");
- this.edt_InsuAmt.Text = "0.00";
- e.Handled = true;
- }
- //第一位是0,第二位必须为小数点
- if (e.KeyChar != (char)('.') && ((TextBox)sender).Text == "0")
- {
- MessageBox.Show("请输入正确的数字");
- this.edt_InsuAmt.Text = "0.00";
- e.Handled = true;
- }
- //第一位是负号,第二位不能为小数点
- if (((TextBox)sender).Text == "-" && e.KeyChar == (char)('.'))
- {
- MessageBox.Show("请输入正确的数字");
- this.edt_InsuAmt.Text = "0.00";
- e.Handled = true;
- }
- }
- #region 控制只能输入整数或小数(供TextBox注册KeyPress事件)
- /**//// <summary>
- /// 控制只能输入整数或小数
- /// (小数位最多位4位,小数位可以自己修改)
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Txb_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
- {
- if (!(((e.KeyChar >= '0') && (e.KeyChar <= '9')) || e.KeyChar <= 31))
- {
- if (e.KeyChar == '.')
- {
- if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
- e.Handled = true;
- }
- else
- e.Handled = true;
- }
- else
- {
- if (e.KeyChar <= 31)
- {
- e.Handled = false;
- }
- else if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
- {
- if (((TextBox)sender).Text.Trim().Substring(((TextBox)sender).Text.Trim().IndexOf('.') + 1).Length >= 4)
- e.Handled = true;
- }
- }
- }
- #endregion
- private void SettlementInfoIP_Load(object sender, EventArgs e)
- {
- SettleMentAmt();
- edt_InsuAmt.Focus();
- edt_InsuAmt.SelectAll();
- }
- private void edt_AcctPayAmt_MouseLeave(object sender, EventArgs e)
- {
- SettleMentAmt();
- }
- private void edt_InsuAmt_MouseLeave(object sender, EventArgs e)
- {
- SettleMentAmt();
- }
- }
- }
|