SettlementInfoIP.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using PTMedicalInsurance.Variables;
  11. namespace PTMedicalInsurance.Forms
  12. {
  13. public partial class SettlementInfoIP : Form
  14. {
  15. public decimal hisSumAmt { get; set; }
  16. public decimal hisPreAmt { get; set; }
  17. public decimal acctPayAmt { get; set; }
  18. public decimal insuAmt { get; set; }
  19. public decimal cashpayAmt { get; set; }
  20. public SettlementInfoIP(string hisAmt,string hisPreAmt)
  21. {
  22. InitializeComponent();
  23. this.StartPosition = FormStartPosition.CenterParent;
  24. edt_HisSumAmt.Text = hisAmt;
  25. edt_PreAmt.Text = hisPreAmt;
  26. }
  27. public void SettleMentAmt()
  28. {
  29. if (IsMoney(edt_AcctPayAmt.Text) == false)
  30. {
  31. MessageBox.Show("请重新输入正确的医保个人账户支付金额");
  32. return;
  33. }
  34. if (IsMoney(edt_InsuAmt.Text) == false)
  35. {
  36. MessageBox.Show("请重新输入正确的医保基金支付金额");
  37. return;
  38. }
  39. hisSumAmt = decimal.Parse(edt_HisSumAmt.Text);
  40. hisPreAmt = decimal.Parse(edt_PreAmt.Text);
  41. acctPayAmt = decimal.Parse(edt_AcctPayAmt.Text);
  42. insuAmt = decimal.Parse(edt_InsuAmt.Text);
  43. edt_cashPayAmt.Text = (Math.Abs(hisSumAmt) - Math.Abs(hisPreAmt) - Math.Abs(acctPayAmt) - Math.Abs(insuAmt)).ToString();
  44. }
  45. private void btnOK_Click(object sender, EventArgs e)
  46. {
  47. if (IsMoney(edt_AcctPayAmt.Text) == false)
  48. {
  49. MessageBox.Show("请重新输入正确的医保个人账户支付金额");
  50. return;
  51. }
  52. if (IsMoney(edt_InsuAmt.Text) == false)
  53. {
  54. MessageBox.Show("请重新输入正确的医保基金支付金额");
  55. return;
  56. }
  57. if (double.Parse(edt_HisSumAmt.Text) <= 0)
  58. {
  59. MessageBox.Show("该患者住院费用总额异常,请检查!");
  60. return;
  61. }
  62. hisSumAmt = decimal.Parse(edt_HisSumAmt.Text);
  63. hisPreAmt = decimal.Parse(edt_PreAmt.Text);
  64. acctPayAmt = decimal.Parse(edt_AcctPayAmt.Text);
  65. insuAmt = decimal.Parse(edt_InsuAmt.Text);
  66. //cashpayAmt = double.Parse(edt_cashPayAmt.Text);
  67. cashpayAmt = Math.Abs(hisSumAmt) - Math.Abs(hisPreAmt) - Math.Abs(acctPayAmt) - Math.Abs(insuAmt);
  68. if (cashpayAmt < 0)
  69. {
  70. MessageBox.Show("【HIS总金额" + hisSumAmt.ToString() + "】-【预交金额" + hisPreAmt.ToString() + "】-【医保基金支付金额" + insuAmt.ToString() + "】-【医保个人账户支付金额" + acctPayAmt.ToString() + "】= 【现金支付金额" + cashpayAmt.ToString() + "】,现金支付金额小于0,请检查!");
  71. return;
  72. }
  73. this.DialogResult = DialogResult.OK;
  74. }
  75. private void btnCancel_Click(object sender, EventArgs e)
  76. {
  77. this.DialogResult = DialogResult.Cancel;
  78. }
  79. public static bool IsMoney(string input)
  80. {
  81. string pattern = @"^\-{0,1}[0-9]{0,}\.{0,1}[0-9]{1,}$";
  82. return System.Text.RegularExpressions.Regex.IsMatch(input, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
  83. }
  84. private void edt_InsuAmt_KeyPress11(object sender, KeyPressEventArgs e)
  85. {
  86. //允许输入数字、小数点、删除键和负号
  87. if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.') && e.KeyChar != (char)('-'))
  88. {
  89. MessageBox.Show("请输入正确的数字");
  90. this.edt_InsuAmt.Text = "0.00";
  91. e.Handled = true;
  92. }
  93. if (e.KeyChar == (char)('-'))
  94. {
  95. if (edt_InsuAmt.Text != "")
  96. {
  97. MessageBox.Show("请输入正确的数字");
  98. this.edt_InsuAmt.Text = "0.00";
  99. e.Handled = true;
  100. }
  101. }
  102. //小数点只能输入一次
  103. if (e.KeyChar == (char)('.') && ((TextBox)sender).Text.IndexOf('.') != -1)
  104. {
  105. MessageBox.Show("请输入正确的数字");
  106. this.edt_InsuAmt.Text = "0.00";
  107. e.Handled = true;
  108. }
  109. //第一位不能为小数点
  110. if (e.KeyChar == (char)('.') && ((TextBox)sender).Text == "")
  111. {
  112. MessageBox.Show("请输入正确的数字");
  113. this.edt_InsuAmt.Text = "0.00";
  114. e.Handled = true;
  115. }
  116. //第一位是0,第二位必须为小数点
  117. if (e.KeyChar != (char)('.') && ((TextBox)sender).Text == "0")
  118. {
  119. MessageBox.Show("请输入正确的数字");
  120. this.edt_InsuAmt.Text = "0.00";
  121. e.Handled = true;
  122. }
  123. //第一位是负号,第二位不能为小数点
  124. if (((TextBox)sender).Text == "-" && e.KeyChar == (char)('.'))
  125. {
  126. MessageBox.Show("请输入正确的数字");
  127. this.edt_InsuAmt.Text = "0.00";
  128. e.Handled = true;
  129. }
  130. }
  131. #region 控制只能输入整数或小数(供TextBox注册KeyPress事件)
  132. /**//// <summary>
  133. /// 控制只能输入整数或小数
  134. /// (小数位最多位4位,小数位可以自己修改)
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void Txb_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
  139. {
  140. if (!(((e.KeyChar >= '0') && (e.KeyChar <= '9')) || e.KeyChar <= 31))
  141. {
  142. if (e.KeyChar == '.')
  143. {
  144. if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
  145. e.Handled = true;
  146. }
  147. else
  148. e.Handled = true;
  149. }
  150. else
  151. {
  152. if (e.KeyChar <= 31)
  153. {
  154. e.Handled = false;
  155. }
  156. else if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
  157. {
  158. if (((TextBox)sender).Text.Trim().Substring(((TextBox)sender).Text.Trim().IndexOf('.') + 1).Length >= 4)
  159. e.Handled = true;
  160. }
  161. }
  162. }
  163. #endregion
  164. private void SettlementInfoIP_Load(object sender, EventArgs e)
  165. {
  166. SettleMentAmt();
  167. edt_InsuAmt.Focus();
  168. edt_InsuAmt.SelectAll();
  169. }
  170. private void edt_AcctPayAmt_MouseLeave(object sender, EventArgs e)
  171. {
  172. SettleMentAmt();
  173. }
  174. private void edt_InsuAmt_MouseLeave(object sender, EventArgs e)
  175. {
  176. SettleMentAmt();
  177. }
  178. }
  179. }