using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using SOH.Kernel; using EAS; using EAS.Services; using SOH.BLL; using SOH.Entities.DTO; using SOH.Data; using SOH.Entities; namespace SOH.ShouFei { [ModuleAttribute(ModuleID = "B456BFAC-4528-4B36-A386-D2AC5F912142", ModuleName = "收费")] public partial class frmShouFei : SOH.Window.baseChildForm { public frmShouFei() { InitializeComponent(); dgv_jjx.AutoGenerateColumns = false; dgv_sflb.AutoGenerateColumns = false; } private void btn_shuxian_Click(object sender, EventArgs e) { //labpd.Visible = false; //labpd.Text = ""; this.textBox1.Text = ""; var vser = ServiceContainer.GetService(); var gzb = vser.getXuYaoShouFei(short.Parse(LoginUser.yydm)); dtogzbBindingSource.DataSource = gzb; } private void dgv_sflb_SelectionChanged(object sender, EventArgs e) { if (dgv_sflb.SelectedRows.Count > 0) { //清除某些信息 //labpd.Visible = false; //labpd.Text = ""; //dgv_jjx.DataSource = null; txt_hj.Text = txt_xj.Text = txt_yhk.Text = txt_zl.Text = txt_sxj.Text = txt_zfb.Text = txt_weixin.Text = txt_yjje.Text = txt_zp.Text = txt_mf.Text=txt_gz.Text = txt_taocan.Text = txt_shouka.Text = "0.00"; txt_xm.Text = txt_xb.Text = txt_tmh.Text = txt_hyh.Text = txt_nl.Text = txt_tjdw.Text = txt_tjtc.Text = ""; //this.dgv_sflb.DataSource //btn_shuxian_Click(null, null); var sdgvr = dgv_sflb.SelectedRows[0]; dto_gzb gzb = sdgvr.DataBoundItem as dto_gzb; txt_tmh.Text = gzb.tm.ToString(); txt_hyh.Text = gzb.hyh.ToString(); txt_nl.Text = gzb.nl.ToString(); txt_xm.Text = gzb.xm; txt_xb.Text = gzb.v_xb; if (gzb.lx == 1) { txt_tjdw.Text = "个人体检"; var vtcser = ServiceContainer.GetService(); var tc = vtcser.GetModelBytcbm(gzb.tcbm); txt_tjtc.Text = tc.tcmc; } else { var vtjxx = ServiceContainer.GetService(); var khfz = vtjxx.getkhfzbytm(gzb.tm); txt_tjdw.Text = gzb.khmc = khfz.khmc; txt_tjtc.Text = gzb.tcmc = khfz.fzmc; } var vser = ServiceContainer.GetService(); string zhxm = vser.getjjxmxbytm(gzb.tm); DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject(zhxm); if (dt.Rows.Count > 0) { DataRow[] drs = dt.Select("jjx=1"); foreach (DataRow dr in drs) { DataRow[] drs1 = dt.Select("jjx=-1 and zhbm=" + dr["zhbm"].ToString()); if (drs1.Length > 0) { dt.Rows.Remove(drs1[0]); } } } dgv_jjx.DataSource = dt; if (gzb.tmztz == 1) { txt_yjje.Text = gzb.tjzje.ToString(); //if (dt.Rows.Count > 0) //{ // txt_yjje.Text = dt.Rows[0]["fzjg"].ToString(); //} //else //{ // txt_yjje.Text = "0"; // MessageBox.Show("套餐信息异常请处理!"); //} } else { if (dt.Rows.Count > 0) { int jjxsfAll = 0; for (int z = 0; z < dt.Rows.Count; z++) { if (dt.Rows[z]["jjx"].ToString() == "0" || dt.Rows[z]["jjx"].ToString() == "-1") { decimal jxsfd = Convert.ToDecimal(dt.Rows[z]["jg"]) * Convert.ToDecimal(dt.Rows[z]["zl"]); int jxsfi = (int)jxsfd; jjxsfAll += jxsfi; } } //txt_yjje.Text = dt.Compute("sum(jjxje)", "jjx=0 or jjx=-1").ToString(); //double dtemp = 0; //double.TryParse(txt_yjje.Text, out dtemp); //int dd = (int)dtemp; //txt_yjje.Text = dd.ToString(); txt_yjje.Text = jjxsfAll.ToString(); } else { txt_yjje.Text = "0"; } } } } private void txt_sxj_Leave(object sender, EventArgs e) { double xj = 0; if (double.TryParse(txt_sxj.Text.Trim(), out xj)) { checkqian(); } else { MessageBox.Show("请输入合法的现金!"); txt_sxj.Focus(); } } private bool checkqian(bool show = false) { bool rb = false; double yjje = 0; if (!double.TryParse(txt_yjje.Text.Trim(), out yjje)) { MessageBox.Show("应交金额有错误,请检查!"); //txt_yjje.Focus(); return rb; } //throw new NotImplementedException(); double yhk = 0; if (!double.TryParse(txt_yhk.Text.Trim(), out yhk)) { MessageBox.Show("请输入合法的银行卡金额!"); txt_yhk.Focus(); return rb; } if (yhk > yjje) { MessageBox.Show("银行卡金额不能大于应缴金额!"); return rb; } double zp = 0; if (!double.TryParse(txt_zp.Text.Trim(), out zp)) { MessageBox.Show("请输入合法的体检卡金额!"); txt_zp.Focus(); return rb; } if (zp > yjje) { MessageBox.Show("体检卡金额不能大于应缴金额!"); return rb; } double zfb = 0; if (!double.TryParse(txt_zfb.Text.Trim(), out zfb)) { MessageBox.Show("请输入合法的支付宝金额!"); txt_zfb.Focus(); return rb; } if (zfb > yjje) { MessageBox.Show("支付宝金额不能大于应缴金额!"); return rb; } double weixin = 0; if (!double.TryParse(txt_weixin.Text.Trim(), out weixin)) { MessageBox.Show("请输入合法的微信金额!"); txt_weixin.Focus(); return rb; } if (weixin > yjje) { MessageBox.Show("微信金额不能大于应缴金额!"); return rb; } double mf = 0; if (!double.TryParse(txt_mf.Text.Trim(), out mf)) { MessageBox.Show("请输入合法的免费金额"); txt_mf.Focus(); return rb; } if (mf > yjje) { MessageBox.Show("免费金额不能大于应缴金额"); return rb; } double gz = 0; if (!double.TryParse(txt_gz.Text.Trim(), out gz)) { MessageBox.Show("请输入合法的挂账金额"); txt_gz.Focus(); return rb; } if (gz > yjje) { MessageBox.Show("挂账金额不能大于应缴金额"); return rb; } double tc = 0; if (!double.TryParse(txt_taocan.Text.Trim(), out tc)) { MessageBox.Show("请输入合法的网上套餐金额!"); txt_taocan.Focus(); return rb; } if (tc > yjje) { MessageBox.Show("网上套餐金额不能大于应缴金额!"); return rb; } double sk = 0; if (!double.TryParse(txt_shouka.Text.Trim(), out sk)) { MessageBox.Show("请输入合法的售卡金额!"); txt_shouka.Focus(); return rb; } if (sk > yjje) { MessageBox.Show("售卡金额不能大于应缴金额!"); return rb; } if ((zp + yhk + mf + tc + sk + zfb+weixin+gz) > yjje) { MessageBox.Show("金额合计不能大于应缴金额!"); return rb; } double xj = 0; if (!double.TryParse(txt_sxj.Text.Trim(), out xj)) { MessageBox.Show("请输入合法的现金金额!"); txt_sxj.Focus(); return rb; } if (xj < 0) { MessageBox.Show("现金不能小于0!"); return rb; } if ((xj + zp + yhk + mf+gz + tc + sk + zfb+weixin) >= yjje) { txt_xj.Text = (yjje - (zp + yhk + mf+gz + tc + sk + zfb+weixin)).ToString("N2"); txt_zl.Text = ((xj + zp + yhk + mf+gz + tc + sk + zfb+weixin) - yjje).ToString("N2"); txt_hj.Text = yjje.ToString("N2"); return true; } else { txt_xj.Text = (xj).ToString("N2"); txt_zl.Text = 0.ToString("N2");// ((xj + zp + yhk) - yjje).ToString("N2"); txt_hj.Text = (xj + zp + yhk + mf+gz + tc + sk + zfb+weixin).ToString("N2"); if (show) { MessageBox.Show("交费金额与应缴金额不符!"); } return false; } } private void txt_yhk_Leave(object sender, EventArgs e) { checkqian(); } private void txt_zp_Leave(object sender, EventArgs e) { checkqian(); } private void btn_shoufei_Click(object sender, EventArgs e) { if (dgv_sflb.SelectedRows.Count > 0) { if (checkqian(true)) { if (double.Parse(txt_zl.Text) > 0) { if (MessageBox.Show("收费" + txt_sxj.Text + ",找零钱" + txt_zl.Text + ",确定吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.No) { return; } } var sdgvr = dgv_sflb.SelectedRows[0]; dto_gzb gzb = sdgvr.DataBoundItem as dto_gzb; var vser = ServiceContainer.GetService(); double xj = double.Parse(txt_xj.Text.Trim()); double yhk = double.Parse(txt_yhk.Text.Trim()); double zp = double.Parse(txt_zp.Text.Trim()); double mf = double.Parse(txt_mf.Text.Trim()); double gz = double.Parse(txt_gz.Text.Trim()); double wstc = double.Parse(txt_taocan.Text.Trim()); double shouka = double.Parse(txt_shouka.Text.Trim()); double zfb = double.Parse(txt_zfb.Text.Trim()); double weixin = double.Parse(txt_weixin.Text.Trim()); int zje = (int)(xj + yhk + zp + mf+gz + wstc + shouka + zfb+weixin); List sfmx = new List(); if (xj > 0) sfmx.Add(new dto_sfmx { je = (int)(xj * 100), lx = 0 }); if (yhk > 0) sfmx.Add(new dto_sfmx { je = (int)(yhk * 100), lx = 1 }); if (zp > 0) sfmx.Add(new dto_sfmx { je = (int)(zp * 100), lx = 2 }); if (mf > 0) { sfmx.Add(new dto_sfmx { je = (int)(mf * 100), lx = 4 }); } if (gz > 0) { sfmx.Add(new dto_sfmx { je = (int)(gz * 100), lx = 7 }); } if (wstc > 0) { sfmx.Add(new dto_sfmx { je = (int)(wstc * 100), lx = 5 }); } if (shouka > 0) { sfmx.Add(new dto_sfmx { je = (int)(shouka * 100), lx = 8 }); } if (zfb > 0) { sfmx.Add(new dto_sfmx { je = (int)(zfb * 100), lx = 3 }); } if (weixin > 0) { sfmx.Add(new dto_sfmx { je = (int)(weixin * 100), lx = 6 }); } List nody = vser.getycztm(gzb.tm); //System.Configuration.Configuration cm = System.Configuration.ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.BaseDirectory + "\\local.ext"); //string isOpen = cm.AppSettings.Settings["isOpenPaidui"].Value; var FenDianService = ServiceContainer.GetService(); FenDian fd = FenDianService.getFenDianById(Convert.ToInt32(LoginUser.yydm)); short sfjx = gzb.tmztz; OperationResult or = vser.ShouFei(gzb, sfmx, short.Parse(LoginUser.yydm), LoginUser.username, zje, fd.isPaidui.ToString(), LoginUser.xm); MessageBox.Show(or.Message); labpd.Visible = true; labpd.Text = or.Message; if (or.State == 1) { //清除某些信息 dgv_jjx.DataSource = null; txt_hj.Text = txt_xj.Text = txt_yhk.Text = txt_zl.Text = txt_sxj.Text = txt_zfb.Text = txt_weixin.Text = txt_yjje.Text = txt_zp.Text = txt_mf.Text=txt_gz.Text = txt_taocan.Text = txt_shouka.Text= "0.00"; txt_xm.Text = txt_xb.Text = txt_tmh.Text = txt_hyh.Text = txt_nl.Text = txt_tjdw.Text = txt_tjtc.Text = ""; //this.dgv_sflb.DataSource btn_shuxian_Click(null, null); if (gzb.tmztz == 1) { if (MessageBox.Show("是否打印导检卡?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { frmPrintDaoJianDan djd = new frmPrintDaoJianDan(); djd.init(gzb.tm); djd.print(); } } frmprinttm ftm = new frmprinttm(); if (sfjx==3) { ftm.init(gzb.tm, 0, 8888, nody); } else { ftm.init(gzb.tm, 0, 0, nody); } ftm.print(); if (fd.fddm == 2) { if (or.Tag.Length > 0) { T_drxpjl xpjl = vser.getXpjl(Convert.ToInt32(or.Tag)); dto_xpdy xpdy = new dto_xpdy { fdmc = fd.fdmc, tm = xpjl.tm, xm = xpjl.xm, dw = xpjl.dw, xb = gzb.xb, nl = gzb.nl, xj = xpjl.pay, yhk = xpjl.bank, zfb = xpjl.cash, weixin = xpjl.sex, sfxm = xpjl.tcorfzname, sfsj = xpjl.rq, sfje = xpjl.shouldpay, czy = xpjl.age }; if(!xpjl.pay.Equals("0")|| !xpjl.bank.Equals("0")|| !xpjl.cash.Equals("0") || !xpjl.sex.Equals("0")) { frmPrintXiaoPiao fxp = new frmPrintXiaoPiao(); fxp.init(xpdy, "客户"); fxp.print(); System.Threading.Thread.Sleep(5000); frmPrintXiaoPiao fxp1 = new frmPrintXiaoPiao(); fxp1.init(xpdy, "财务"); fxp1.print(); } } } } } } else { MessageBox.Show("请选择要收费的信息!"); } } private void dgv_jjx_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { //128, 255, 128 foreach (DataGridViewRow dgvr in dgv_jjx.Rows) { var drv = dgvr.DataBoundItem as DataRowView; var jjx = int.Parse(drv.Row["jjx"].ToString()); if (jjx == 0) { dgvr.DefaultCellStyle.BackColor = Color.FromArgb(128, 255, 128); } else if (jjx == 1) { dgvr.DefaultCellStyle.BackColor = Color.FromArgb(255, 128, 128); } } } private void txt_mf_Leave(object sender, EventArgs e) { checkqian(); } private void btnCX_Click(object sender, EventArgs e) { //根据会员号查询 string hyhstr = this.textBox1.Text.Trim(); if (string.IsNullOrEmpty(hyhstr)) { var vser = ServiceContainer.GetService(); var gzb = vser.getXuYaoShouFei(short.Parse(LoginUser.yydm)); dtogzbBindingSource.DataSource = gzb; } else { int hyh = 0; if (Int32.TryParse(hyhstr, out hyh)) { var vser = ServiceContainer.GetService(); var gzb = vser.getXuYaoShouFei(short.Parse(LoginUser.yydm), hyh); dtogzbBindingSource.DataSource = gzb; } } } /// /// 取消登记的查询 /// /// /// private void button3_Click(object sender, EventArgs e) { string tmstr = this.tbTM.Text.Trim(); if (string.IsNullOrEmpty(tmstr) || tmstr.Length != 10) { ClearQXDJ(); MessageBox.Show("条码号格式错误"); return; } int tm = 0; Int32.TryParse(tmstr, out tm); if (tm == 0) { ClearQXDJ(); MessageBox.Show("条码号格式错误"); return; } //根据tm获取登记信息 var vs = ServiceContainer.GetService(); dto_tjdjxx tdtj = vs.GetTjdjxxAll(tm); if (tdtj == null) { ClearQXDJ(); MessageBox.Show("未能找到对应条码的登记信息"); return; } //if (tdtj.lx == 0) //个检 //{ // if (tdtj.tmztz == 1) // { // } // else // { // MessageBox.Show("该人员当前状态不能取消登记"); // ClearQXDJ(); // return; // } //} //else //团检 //{ //} if (tdtj.tmztz == 1) { this.tbTM.Text = tm.ToString(); this.tbTMH.Text = tm.ToString(); this.tbXM.Text = tdtj.xm; this.tbXB.Text = tdtj.xb == 0 ? "男" : (tdtj.xb == 1 ? "女" : ""); this.tbNL.Text = tdtj.nl.ToString(); this.tbHY.Text = tdtj.hyzk == 0 ? "未婚" : (tdtj.hyzk == 1 ? "已婚" : ""); this.tbYGH.Text = tdtj.ygh; this.tbBM.Text = tdtj.ssbm; } else { MessageBox.Show("该人员当前状态不能取消登记"); ClearQXDJ(); return; } } /// /// 取消登记窗体清空信息 /// private void ClearQXDJ() { this.tbTM.Text = ""; this.tbXM.Text = ""; this.tbXB.Text = ""; this.tbNL.Text = ""; this.tbHY.Text = ""; this.tbYGH.Text = ""; this.tbBM.Text = ""; } private void button5_Click(object sender, EventArgs e) { ClearQXDJ(); } //取消登记 private void button4_Click(object sender, EventArgs e) { string tmstr = this.tbTMH.Text.Trim(); string xmstr = this.tbXM.Text.Trim(); if (string.IsNullOrEmpty(tmstr) || string.IsNullOrEmpty(xmstr)) { MessageBox.Show("请先输入条码号查询后操作"); return; } else { int tm = 0; Int32.TryParse(tmstr, out tm); //根据tm取消登记 } } private void frmShouFei_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { } private void txt_zfb_Leave(object sender, EventArgs e) { double zfb = 0; if (double.TryParse(txt_zfb.Text.Trim(), out zfb)) { checkqian(); } else { MessageBox.Show("请输入合法的金额!"); txt_zfb.Focus(); } } private void txt_weixin_Leave(object sender, EventArgs e) { double weixin = 0; if (double.TryParse(txt_weixin.Text.Trim(), out weixin)) { checkqian(); } else { MessageBox.Show("请输入合法的金额!"); txt_weixin.Focus(); } } private void txt_gz_Leave(object sender, EventArgs e) { double gz = 0; if (double.TryParse(txt_gz.Text.Trim(), out gz)) { checkqian(); } else { MessageBox.Show("请输入合法的金额!"); txt_gz.Focus(); } } private void txt_taocan_Leave(object sender, EventArgs e) { double tc = 0; if (double.TryParse(txt_taocan.Text.Trim(), out tc)) { checkqian(); } else { MessageBox.Show("请输入合法的金额!"); txt_taocan.Focus(); } } private void txt_shouka_Leave(object sender, EventArgs e) { double sk = 0; if (double.TryParse(txt_shouka.Text.Trim(), out sk)) { checkqian(); } else { MessageBox.Show("请输入合法的金额!"); txt_shouka.Focus(); } } } }