/// <summary> /// 结帐 /// </summary> public void m_mthCharge() { if (this.m_objViewer.ucPatientInfo.BihPatient_VO.Status == 3 && this.m_objViewer.ucPatientInfo.BihPatient_VO.FeeStatus != 4) { MessageBox.Show("该病人已办理出院结算,当前为查询状态。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (m_intParm1068 != 0) { ////////结算前判断病人在门诊是否用未交费用的处方,给出提示 string strMessage = ""; clsPublic.m_lngSelectPatientNoPayRecipe(this.m_objViewer.ucPatientInfo.BihPatient_VO.RegisterID, out strMessage); if (!string.IsNullOrEmpty(strMessage)) { if (m_intParm1068 == 1) { if (MessageBox.Show("是否允许结算" + strMessage, "病人门诊费用未清!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; } } else if (m_intParm1068 == 2) { MessageBox.Show("不允许结算" + strMessage, "病人门诊费用未清!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } ////////////////// } if (ChargeDtSelect == null || ChargeDtSelect.Rows.Count == 0) { if (MessageBox.Show("该病人在住院期间没有发生任何费用,是否直接办理出院?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { frmReckoning f = new frmReckoning(this.m_objViewer.InvoNo); if (this.m_objViewer.ucPatientInfo.BihPatient_VO.FeeStatus == 4) { f.ChargeType = 6; } else { f.ChargeType = 2; } f.ChargeDetail = null; f.objPatient = this.m_objViewer.ucPatientInfo; f.DayChrgType = 0; f.DayAccountsArr = null; f.DirectChargeOut = true; if (f.ShowDialog() == DialogResult.OK) { this.m_objViewer.ucPatientInfo.m_mthShortCurFind(); } } return; } #region 获取帐期信息 //结算类型 1 帐期 2 明细 int DayChrgType = 1; Hashtable has = new Hashtable(); for (int i = 0; i < ChargeDtSelect.Rows.Count; i++) { string dayid = ChargeDtSelect.Rows[i]["dayaccountid_chr"].ToString(); if (!has.ContainsKey(dayid)) { has.Add(dayid, null); } } ArrayList DayaccountsNoArr = new ArrayList(); DayaccountsNoArr.AddRange(has.Keys); DataView dvDayAll = new DataView(ChargeDt); DataView dvDaySub = new DataView(ChargeDtSelect); ArrayList DayAccountsArr = new ArrayList(); for (int i = 0; i < DayaccountsNoArr.Count; i++) { string dayid = DayaccountsNoArr[i].ToString(); clsBihDayAccounts_VO DayAccounts_VO = new clsBihDayAccounts_VO(); DayAccounts_VO.AccountsID = dayid; DayAccounts_VO.ChargeEmp = this.m_objViewer.LoginInfo.m_strEmpID; dvDayAll.RowFilter = "dayaccountid_chr = '" + dayid + "'"; dvDaySub.RowFilter = "dayaccountid_chr = '" + dayid + "'"; decimal decTotalSum = 0; decimal decSbSum = 0; decimal decAcctSum = 0; foreach (DataRowView drv in dvDayAll) { decimal d = clsPublic.ConvertObjToDecimal(drv["unitprice_dec"]) * clsPublic.ConvertObjToDecimal(drv["amount_dec"]); decTotalSum += clsPublic.Round(d, 2); decSbSum += clsPublic.Round(d * clsPublic.ConvertObjToDecimal(drv["precent_dec"]) / 100, 2); } decAcctSum = decTotalSum - decSbSum; DayAccounts_VO.TotalSum = decTotalSum; DayAccounts_VO.SbSum = decSbSum; DayAccounts_VO.AcctSum = decAcctSum; decTotalSum = 0; decSbSum = 0; decAcctSum = 0; foreach (DataRowView drv in dvDaySub) { decimal d = clsPublic.ConvertObjToDecimal(drv["unitprice_dec"]) * clsPublic.ConvertObjToDecimal(drv["amount_dec"]); decTotalSum += clsPublic.Round(d, 2); decSbSum += clsPublic.Round(d * clsPublic.ConvertObjToDecimal(drv["precent_dec"]) / 100, 2); } decAcctSum = decTotalSum - decSbSum; DayAccounts_VO.ClearSbSum = decSbSum; DayAccounts_VO.ClearAcctSum = decAcctSum; DayAccountsArr.Add(DayAccounts_VO); } #endregion //只能结算待结、待清费用 DataView dv = new DataView(ChargeDt); dv.RowFilter = "pstatus_int = 1 or pstatus_int = 2"; DataTable dt = ChargeDt.Clone(); foreach (DataRowView drv in dv) { dt.Rows.Add(drv.Row.ItemArray); } dt.AcceptChanges(); frmReckoning frec = new frmReckoning(this.m_objViewer.InvoNo); if (this.m_objViewer.ucPatientInfo.BihPatient_VO.FeeStatus == 4) { frec.ChargeType = 6; } else { frec.ChargeType = 2; } frec.ChargeDetail = dt; frec.objPatient = this.m_objViewer.ucPatientInfo; frec.DayChrgType = DayChrgType; frec.DayAccountsArr = DayAccountsArr; if (frec.ShowDialog() == DialogResult.OK) { this.m_objViewer.ucPatientInfo.m_mthShortCurFind(); } }
/// <summary> /// 结帐 /// </summary> public void m_mthCharge() { if (ChargeDtSelect == null || ChargeDtSelect.Rows.Count == 0) { MessageBox.Show("请选择结帐项目。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #region 获取帐期信息 //结算类型 1 帐期 2 明细 int DayChrgType = 0; ArrayList DayaccountsNoArr = new ArrayList(); if (this.m_objViewer.rdoZq.Checked) { DayChrgType = 1; for (int i = 0; i < this.m_objViewer.dtgMain.Rows.Count; i++) { if (this.m_objViewer.dtgMain.Rows[i].Cells[0].Value.ToString().ToUpper() == "T") { DataRow dr = (DataRow)this.m_objViewer.dtgMain.Rows[i].Tag; DayaccountsNoArr.Add(dr["dayaccountid_chr"].ToString()); } } } else if (this.m_objViewer.rdoMx.Checked) { DayChrgType = 2; //全选明细等同于按帐期结帐 bool b = true; for (int i = 0; i < this.m_objViewer.dtgDetail.Rows.Count; i++) { if (this.m_objViewer.dtgDetail.Rows[i].Cells[0].ReadOnly == true) { continue; } if (this.m_objViewer.dtgDetail.Rows[i].Cells[0].Value.ToString().ToUpper() == "F") { b = false; break; } } if (b) { DayChrgType = 1; } for (int i = 0; i < this.m_objViewer.dtgMain.Rows.Count; i++) { if (this.m_objViewer.dtgMain.Rows[i].Selected) { DataRow dr = (DataRow)this.m_objViewer.dtgMain.Rows[i].Tag; DayaccountsNoArr.Add(dr["dayaccountid_chr"].ToString()); } } } else if (this.m_objViewer.rdoMix.Checked) { DayChrgType = 2; string id = ""; Hashtable hasID = new Hashtable(); for (int i = 0; i < this.ChargeDtSelect.Rows.Count; i++) { id = this.ChargeDtSelect.Rows[i]["dayaccountid_chr"].ToString(); if (!hasID.ContainsKey(id)) { hasID.Add(id, id); } } if (hasID.Count > 0) { DayaccountsNoArr.AddRange(hasID.Values); } } DataView dvDayAll = new DataView(ChargeDt); DataView dvDaySub = new DataView(ChargeDtSelect); ArrayList DayAccountsArr = new ArrayList(); for (int i = 0; i < DayaccountsNoArr.Count; i++) { string dayid = DayaccountsNoArr[i].ToString(); clsBihDayAccounts_VO DayAccounts_VO = new clsBihDayAccounts_VO(); DayAccounts_VO.AccountsID = dayid; DayAccounts_VO.ChargeEmp = this.m_objViewer.LoginInfo.m_strEmpID; dvDayAll.RowFilter = "dayaccountid_chr = '" + dayid + "'"; dvDaySub.RowFilter = "dayaccountid_chr = '" + dayid + "' and pstatus_int = 2"; decimal decTotalSum = 0; decimal decSbSum = 0; decimal decAcctSum = 0; foreach (DataRowView drv in dvDayAll) { decimal d = clsPublic.ConvertObjToDecimal(drv["unitprice_dec"]) * clsPublic.ConvertObjToDecimal(drv["amount_dec"]); decTotalSum += clsPublic.Round(d, 2); decSbSum += clsPublic.Round(d * clsPublic.ConvertObjToDecimal(drv["precent_dec"]) / 100, 2); } decAcctSum = decTotalSum - decSbSum; DayAccounts_VO.TotalSum = decTotalSum; DayAccounts_VO.SbSum = decSbSum; DayAccounts_VO.AcctSum = decAcctSum; decTotalSum = 0; decSbSum = 0; decAcctSum = 0; foreach (DataRowView drv in dvDaySub) { decimal d = clsPublic.ConvertObjToDecimal(drv["unitprice_dec"]) * clsPublic.ConvertObjToDecimal(drv["amount_dec"]); decTotalSum += clsPublic.Round(d, 2); decSbSum += clsPublic.Round(d * clsPublic.ConvertObjToDecimal(drv["precent_dec"]) / 100, 2); } decAcctSum = decTotalSum - decSbSum; DayAccounts_VO.ClearSbSum = decSbSum; DayAccounts_VO.ClearAcctSum = decAcctSum; DayAccountsArr.Add(DayAccounts_VO); } #endregion frmReckoning frec = new frmReckoning(); frec.ChargeType = 1; frec.ChargeDetail = ChargeDtSelect; frec.objPatient = this.m_objViewer.ucPatientInfo; frec.DayChrgType = DayChrgType; frec.DayAccountsArr = DayAccountsArr; if (frec.ShowDialog() == DialogResult.OK) { this.m_objViewer.ucPatientInfo.m_mthShortCurFind(); } }
/// <summary> /// 结帐 /// </summary> public void m_mthCharge() { #region 校验 if (this.m_objViewer.ucPatientInfo.RegisterID.Trim() == "" || this.m_objViewer.dtgDetail.Rows.Count == 0) { return; } if (this.m_objViewer.cboDeptClass.SelectedIndex != 0) { this.m_objViewer.cboDeptClass.SelectedIndex = 0; } //是否有预交金 (true 有 false 无) bool IsHavePrepayMoney = false; if (this.m_objViewer.ucPatientInfo.BihPatient_VO.PrepayMoney > 0) { IsHavePrepayMoney = true; if (!IsCompute) { if (!this.m_mthCompute()) { return; } } } #endregion #region 生成结算分类VO //核算分类 ArrayList ChargeCatArr = new ArrayList(); if (IsHavePrepayMoney) { if (intBabyParm == 0) { #region 普通模式 for (int i = 0; i < this.m_objViewer.dtgDetail.Rows.Count; i++) { if (this.m_objViewer.dtgDetail.Rows[i].Cells["colflmc"].Value.ToString().IndexOf("科室小计") >= 0) { continue; } DataRow dr = this.m_objViewer.dtgDetail.Rows[i].Tag as DataRow; if (dr["typename_vchr"].ToString().Trim() == "") { MessageBox.Show("收费明细存在住院核算分类为空,操作终止。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } clsBihChargeCat_VO ChargeCat_VO = new clsBihChargeCat_VO(); ChargeCat_VO.DeptID = dr["deptid"].ToString(); ChargeCat_VO.ItemCatID = dr["calccateid_chr"].ToString(); ChargeCat_VO.TotalSum = clsPublic.ConvertObjToDecimal(this.m_objViewer.dtgDetail.Rows[i].Cells["colftje"].Value); ChargeCat_VO.AcctSum = 0; ChargeCatArr.Add(ChargeCat_VO); } #endregion } else { #region 母婴合并结算生成结算类VO int intTempRows = 0; DataTable dtbMater = new DataTable(); DataTable dtbBaby = new DataTable(); dtbMater.Columns.Add("deptid"); dtbMater.Columns.Add("calccateid_chr"); dtbMater.Columns.Add("TotalSum"); dtbBaby.Columns.Add("deptid"); dtbBaby.Columns.Add("calccateid_chr"); dtbBaby.Columns.Add("TotalSum"); string[] sarr = new string[3]; for (int i = 0; i < this.m_objViewer.dtgDetail.Rows.Count; i++) { if (this.m_objViewer.dtgDetail.Rows[i].Cells["colflmc"].Value.ToString().IndexOf("科室小计") >= 0) { continue; } else if (this.m_objViewer.dtgDetail.Rows[i].Cells["colflmc"].Value.ToString().IndexOf("--------") >= 0) { intTempRows = i + 1; break; } DataRow dr = this.m_objViewer.dtgDetail.Rows[i].Tag as DataRow; if (dr["typename_vchr"].ToString().Trim() == "") { MessageBox.Show("收费明细存在住院核算分类为空,操作终止。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } sarr[0] = dr["deptid"].ToString(); sarr[1] = dr["calccateid_chr"].ToString(); sarr[2] = this.m_objViewer.dtgDetail.Rows[i].Cells["colhjje"].Value.ToString(); dtbMater.Rows.Add(sarr); //clsBihChargeCat_VO ChargeCat_VO = new clsBihChargeCat_VO(); //ChargeCat_VO.DeptID = dr["deptid"].ToString(); //ChargeCat_VO.ItemCatID = dr["calccateid_chr"].ToString(); //ChargeCat_VO.TotalSum = clsPublic.ConvertObjToDecimal(this.m_objViewer.dtgDetail.Rows[i].Cells["colhjje"].Value); //ChargeCat_VO.AcctSum = 0; //ChargeCatArr.Add(ChargeCat_VO); } //如果有婴儿费用,也分出来计算 if (intTempRows > 0) { for (int i2 = intTempRows; i2 < this.m_objViewer.dtgDetail.Rows.Count; i2++) { if (this.m_objViewer.dtgDetail.Rows[i2].Cells["colflmc"].Value.ToString().IndexOf("科室小计") >= 0) { continue; } DataRow dr = this.m_objViewer.dtgDetail.Rows[i2].Tag as DataRow; if (dr["typename_vchr"].ToString().Trim() == "") { MessageBox.Show("收费明细存在住院核算分类为空,操作终止。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } sarr[0] = dr["deptid"].ToString(); sarr[1] = dr["calccateid_chr"].ToString(); sarr[2] = this.m_objViewer.dtgDetail.Rows[i2].Cells["colhjje"].Value.ToString(); dtbBaby.Rows.Add(sarr); } DataRow drwMater = null; DataRow drwBaby = null; for (int i3 = 0; i3 < dtbMater.Rows.Count; i3++) { drwMater = dtbMater.Rows[i3]; for (int i4 = 0; i4 < dtbBaby.Rows.Count; i4++) { drwBaby = dtbBaby.Rows[i4]; if (drwMater["deptid"].ToString() == drwBaby["deptid"].ToString() && drwMater["calccateid_chr"].ToString() == drwBaby["calccateid_chr"].ToString()) { dtbMater.Rows[i3]["TotalSum"] = Convert.ToDecimal(drwMater["TotalSum"].ToString()) + Convert.ToDecimal(drwBaby["TotalSum"].ToString()); dtbBaby.Rows.RemoveAt(i4); i4--; } } } drwMater = null; drwBaby = null; //将婴儿有的费用类型,母亲没有的也添加进费用分类总表去 if (dtbBaby.Rows.Count > 0) { object[] objarr = null;; for (int i6 = 0; i6 < dtbBaby.Rows.Count; i6++) { objarr = dtbBaby.Rows[i6].ItemArray; dtbMater.Rows.Add(objarr); } objarr = null; } } //所有的费用表生成结算分类费用VO DataRow drwMater2 = null; for (int i5 = 0; i5 < dtbMater.Rows.Count; i5++) { drwMater2 = dtbMater.Rows[i5]; clsBihChargeCat_VO ChargeCat_VO = new clsBihChargeCat_VO(); ChargeCat_VO.DeptID = drwMater2["deptid"].ToString(); ChargeCat_VO.ItemCatID = drwMater2["calccateid_chr"].ToString(); ChargeCat_VO.TotalSum = Convert.ToDecimal(drwMater2["TotalSum"].ToString()); ChargeCat_VO.AcctSum = 0; ChargeCatArr.Add(ChargeCat_VO); } #endregion } } #endregion #region 生成发票分类VO //发票分类 ArrayList ChargeInvArr = new ArrayList(); if (IsHavePrepayMoney) { string RegID = this.m_objViewer.ucPatientInfo.RegisterID.Trim(); DataTable dtFee; long l = 0; if (intBabyParm == 1) { l = this.objSvc.m_lngGetBadChargeFeeInfoMotherBaby(RegID, out dtFee); } else { l = this.objSvc.m_lngGetBadChargeFeeInfo(RegID, out dtFee); } if (l > 0) { DataView dv = new DataView(dtFee); DataTable dtCat = new DataTable(); l = this.objSvc.m_lngGetChargeItemCat(4, out dtCat); if (l > 0 && dtCat.Rows.Count > 0) { decimal decPrepayMny = this.m_objViewer.ucPatientInfo.BihPatient_VO.PrepayMoney; decimal decDeptMny = this.m_objViewer.ucPatientInfo.BihPatient_VO.WaitChargeFee + this.m_objViewer.ucPatientInfo.BihPatient_VO.WaitClearFee; decimal scale = decPrepayMny / decDeptMny; decimal decSum = 0; for (int i = 0; i < dtCat.Rows.Count; i++) { string catid = dtCat.Rows[i]["typeid_chr"].ToString().Trim(); string catname = dtCat.Rows[i]["typename_vchr"].ToString().Trim(); decimal dtotal = 0; dv.RowFilter = "invcateid_chr = '" + catid + "'"; foreach (DataRowView drv in dv) { catid = drv["invcateid_chr"].ToString().Trim(); if (catid == "") { MessageBox.Show("收费明细存在住院发票分类为空,结算终止。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } decimal dc = clsPublic.Round(clsPublic.ConvertObjToDecimal(drv["unitprice_dec"]) * clsPublic.ConvertObjToDecimal(drv["amount_dec"]) * scale, 2); dtotal += dc; } if (dtotal == 0) { continue; } clsBihInvoiceCat_VO InvoiceCat_VO = new clsBihInvoiceCat_VO(); InvoiceCat_VO.ItemCatID = catid; InvoiceCat_VO.ItemCatName = catname; InvoiceCat_VO.TotalSum = dtotal; InvoiceCat_VO.AcctSum = 0; decSum += dtotal; if (i == dtCat.Rows.Count - 1) { if (decSum != decPrepayMny) { InvoiceCat_VO.TotalSum = InvoiceCat_VO.TotalSum + decPrepayMny - decSum; } } ChargeInvArr.Add(InvoiceCat_VO); } } } else { return; } } #endregion frmReckoning frec = new frmReckoning(this.m_objViewer.InvoNo); frec.ChargeType = 3; frec.objPatient = this.m_objViewer.ucPatientInfo; frec.BadChargeCatArr = ChargeCatArr; frec.BadChargeInvArr = ChargeInvArr; frec.BadChargeDiffValDeptID = DiffValDeptID; frec.BadChargeDiffValCatID = DiffValCatID; frec.DirectChargeFlag = !IsHavePrepayMoney; if (frec.ShowDialog() == DialogResult.OK) { this.m_objViewer.btnCompute.Enabled = false; this.m_objViewer.btnCharge.Enabled = false; this.m_objViewer.ucPatientInfo.m_mthShortCurFind(); } }