/// <summary> /// 保存日结数据 /// </summary> public void DayBalance() { if (this.alBalanceData == null) { return; } if (MessageBox.Show("是否进行日结,日结后数据将不能恢复?", "门诊收款员缴款日报", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // // 变量定义 // // 返回值 int intReturn = 0; // 事务对象 //Neusoft.FrameWork.Management.Transaction transaction = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance); // 等待窗口 Neusoft.FrameWork.WinForms.Forms.frmWait waitForm = new Neusoft.FrameWork.WinForms.Forms.frmWait(); // 门诊收费业务层 Neusoft.HISFC.BizLogic.Fee.Outpatient outpatient = new Neusoft.HISFC.BizLogic.Fee.Outpatient(); // 日结序号 string sequence = ""; // // 判断合法性 // if (!this.enableBalance) { MessageBox.Show("不能进行日结"); return; } if (this.alBalanceData == null) { return; } // 启动等待窗口 waitForm.Tip = "正在进行日结"; waitForm.Show(); // // 设置事务 // Neusoft.FrameWork.Management.PublicTrans.BeginTransaction(); //transaction.BeginTransaction(); this.clinicDayBalance.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); outpatient.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); // // 保存日结数据 // this.operateDate = this.clinicDayBalance.GetDateTimeFromSysDateTime().ToString(); // 获取日结序号 intReturn = this.clinicDayBalance.GetBalanceSequence(ref sequence); if (intReturn == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); waitForm.Hide(); MessageBox.Show("获取日结序列号失败"); return; } foreach (Class.ClinicDayBalance tempBalance in this.alBalanceData) { tempBalance.BalanceSequence = sequence; tempBalance.BalanceDate = DateTime.Parse(this.operateDate); intReturn = clinicDayBalance.CreateClinicDayBalance(tempBalance); if (intReturn == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); waitForm.Hide(); MessageBox.Show("日结失败" + outpatient.Err); return; } } // // 更新其他表 // // 更新发票主表表FIN_OPB_INVOICEINFO intReturn = outpatient.UpdateInvoiceForDayBalance(DateTime.Parse(this.lastDate), DateTime.Parse(this.dayBalanceDate), "1", sequence, DateTime.Parse(this.operateDate)); if (intReturn <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); waitForm.Hide(); MessageBox.Show("更新发票主表失败" + outpatient.Err); return; } // 更新发票明细表FIN_OPB_INVOICEDETAIL intReturn = outpatient.UpdateInvoiceDetailForDayBalance(DateTime.Parse(this.lastDate), DateTime.Parse(this.dayBalanceDate), "1", sequence, DateTime.Parse(this.operateDate)); if (intReturn <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); waitForm.Hide(); MessageBox.Show("更新发票明细表失败"); return; } // 更新支付情况表FIN_OPB_PAYMODE intReturn = outpatient.UpdatePayModeForDayBalance(DateTime.Parse(this.lastDate), DateTime.Parse(this.dayBalanceDate), "1", sequence, DateTime.Parse(this.operateDate)); if (intReturn <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); waitForm.Hide(); MessageBox.Show("更新支付情况表失败" + outpatient.Err); return; } // // 保存成功 // Neusoft.FrameWork.Management.PublicTrans.Commit(); waitForm.Hide(); MessageBox.Show("日结成功完成"); this.PrintPanel(this.panelPrint); alBalanceData = null; // 设置上次日结时间显示 this.ucClinicDayBalanceDateControl1.tbLastDate.Text = this.dayBalanceDate; this.ucClinicDayBalanceDateControl1.dtpBalanceDate.Value = this.clinicDayBalance.GetDateTimeFromSysDateTime(); } }
/// <summary> /// 重打 /// </summary> /// <returns>成功 true 失败 false</returns> protected virtual bool Print() { if (currentBalance == null) { MessageBox.Show("该发票已经作废!"); this.tbInvoiceNo.Focus(); this.tbInvoiceNo.SelectAll(); return(false); } if (currentBalance.Invoice.ID == "") { MessageBox.Show("请输入发票信息!"); this.tbInvoiceNo.Focus(); this.tbInvoiceNo.SelectAll(); return(false); } bool isCanQuitOtherOper = this.controlParamIntegrate.GetControlParam <bool>(Neusoft.HISFC.BizProcess.Integrate.Const.CAN_REPRINT_OTHER_OPER_INVOICE, true, false); if (!isCanQuitOtherOper)//不予许交叉重打 { Balance tmpInvoice = comBalances[0] as Balance; if (tmpInvoice == null) { MessageBox.Show("发票格式转换出错!"); tbInvoiceNo.SelectAll(); tbInvoiceNo.Focus(); return(false); } if (tmpInvoice.BalanceOper.ID != this.outpatientManager.Operator.ID) { MessageBox.Show("该发票为操作员" + tmpInvoice.BalanceOper.ID + "收取,您没有权限进重打!"); tbInvoiceNo.SelectAll(); tbInvoiceNo.Focus(); return(false); } } bool isCanReprintDayBalance = this.controlParamIntegrate.GetControlParam <bool>(Neusoft.HISFC.BizProcess.Integrate.Const.CAN_REPRINT_DAYBALANCED_INVOICE, true, false); if (!isCanReprintDayBalance)//不予许交叉重打 { Balance tmpInvoice = comBalances[0] as Balance; if (tmpInvoice == null) { MessageBox.Show("发票格式转换出错!"); tbInvoiceNo.SelectAll(); tbInvoiceNo.Focus(); return(false); } if (tmpInvoice.IsDayBalanced) { MessageBox.Show("该发票已经日结,您没有权限进重打!"); tbInvoiceNo.SelectAll(); tbInvoiceNo.Focus(); return(false); } } //Neusoft.FrameWork.Management.Transaction t = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance); //t.BeginTransaction(); Neusoft.FrameWork.Management.PublicTrans.BeginTransaction(); outpatientManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); feeIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); pharmacyIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); controlParamIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); int returnValue = 0; string currentInvoiceNO = ""; string currentRealInvoiceNO = ""; string errText = ""; DateTime nowTime = new DateTime(); nowTime = outpatientManager.GetDateTimeFromSysDateTime(); invoiceType = controlParamIntegrate.GetControlParam <string>(Neusoft.HISFC.BizProcess.Integrate.Const.GET_INVOICE_NO_TYPE, false, "0"); //ArrayList invoicesPrint = new ArrayList(); //ArrayList invoiceDetailsPrintTemp = new ArrayList(); //ArrayList invoiceDetailsPrint = new ArrayList(); //ArrayList feeDetailsPrint = new ArrayList(); //发票 ArrayList invoicesPrint = new ArrayList(); //发票明细 ArrayList invoiceDetailsPrintTemp = new ArrayList(); //发票明细 ArrayList invoiceDetailsPrint = new ArrayList(); //发票费用明细 ArrayList invoicefeeDetailsPrintTemp = new ArrayList(); //发票费用明细 ArrayList invoicefeeDetailsPrint = new ArrayList(); //全部费用明细 ArrayList feeDetailsPrint = new ArrayList(); //获得负发票流水号 string invoiceSeqNegative = outpatientManager.GetInvoiceCombNO(); if (invoiceSeqNegative == null || invoiceSeqNegative == "") { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("获得发票流水号失败!" + outpatientManager.Err); return(false); } //获得正发票流水号 //string invoiceSeqPositive = outpatientManager.GetInvoiceCombNO(); //if (invoiceSeqPositive == null || invoiceSeqPositive == "") //{ // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show("获得发票流水号失败!" + outpatientManager.Err); // return false; //} Hashtable hsInvoice = new Hashtable(); Neusoft.HISFC.Models.Base.Employee employee = this.outpatientManager.Operator as Neusoft.HISFC.Models.Base.Employee; foreach (Balance invoice in comBalances) { //returnValue = this.feeIntegrate.GetInvoiceNO(employee, ref currentInvoiceNO, ref currentRealInvoiceNO, ref errText, null); //if (returnValue == -1) //{ // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show(errText); // return false; //} // hsInvoice.Add(invoice.Invoice.ID, currentInvoiceNO); returnValue = outpatientManager.UpdateBalanceCancelType(invoice.Invoice.ID, invoice.CombNO, nowTime, Neusoft.HISFC.Models.Base.CancelTypes.Reprint); if (returnValue == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("作废原始发票信息出错!" + outpatientManager.Err); return(false); } if (returnValue == 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("该发票已经作废!"); return(false); } //处理冲账信息(负记录) invoice.PrintTime = invoice.BalanceOper.OperTime; Balance invoClone = invoice.Clone(); invoClone.TransType = Neusoft.HISFC.Models.Base.TransTypes.Negative; invoClone.FT.TotCost = -invoClone.FT.TotCost; invoClone.FT.OwnCost = -invoClone.FT.OwnCost; invoClone.FT.PayCost = -invoClone.FT.PayCost; invoClone.FT.PubCost = -invoClone.FT.PubCost; invoClone.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Reprint; invoClone.CanceledInvoiceNO = invoice.Invoice.ID; invoClone.CancelOper.ID = outpatientManager.Operator.ID; invoClone.BalanceOper.ID = outpatientManager.Operator.ID; invoClone.BalanceOper.OperTime = nowTime; invoClone.CancelOper.OperTime = nowTime; invoClone.IsAuditing = false; invoClone.AuditingOper.ID = ""; invoClone.AuditingOper.OperTime = DateTime.MinValue; invoClone.IsDayBalanced = false; invoClone.DayBalanceOper.OperTime = DateTime.MinValue; invoClone.CombNO = invoiceSeqNegative; returnValue = outpatientManager.InsertBalance(invoClone); if (returnValue <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("插入发票冲账信息出错!!" + outpatientManager.Err); return(false); } //invoClone.TransType = Neusoft.HISFC.Models.Base.TransTypes.Positive; //invoClone.FT.TotCost = -invoClone.FT.TotCost; //invoClone.FT.OwnCost = -invoClone.FT.OwnCost; //invoClone.FT.PayCost = -invoClone.FT.PayCost; //invoClone.FT.PubCost = -invoClone.FT.PubCost; //invoClone.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Valid; //invoClone.CanceledInvoiceNO = invoice.Invoice.ID; //invoClone.CancelOper.OperTime = DateTime.MinValue; //invoClone.Invoice.ID = currentInvoiceNO; //invoClone.PrintedInvoiceNO = currentRealInvoiceNO; //invoClone.BalanceOper.ID = outpatientManager.Operator.ID; //invoClone.BalanceOper.OperTime = nowTime; //invoClone.CombNO = invoiceSeqPositive; //invoicesPrint.Add(invoClone); //returnValue = outpatientManager.InsertBalance(invoClone); if (returnValue <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("插入新发票信息出错!" + outpatientManager.Err); return(false); } //处理发票明细表信息 ArrayList alInvoceDetail = outpatientManager.QueryBalanceListsByInvoiceNOAndInvoiceSequence(invoice.Invoice.ID, currentBalance.CombNO); if (comBalanceLists == null) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("获得发票明细出错!" + outpatientManager.Err); return(false); } //作废发票明细表信息 returnValue = outpatientManager.UpdateBalanceListCancelType(invoice.Invoice.ID, currentBalance.CombNO, nowTime, Neusoft.HISFC.Models.Base.CancelTypes.Reprint); if (returnValue <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("作废发票明细出错!" + outpatientManager.Err); return(false); } invoiceDetailsPrintTemp = new ArrayList(); foreach (BalanceList d in alInvoceDetail) { d.BalanceBase.TransType = Neusoft.HISFC.Models.Base.TransTypes.Negative; d.BalanceBase.FT.OwnCost = -d.BalanceBase.FT.OwnCost; d.BalanceBase.FT.PubCost = -d.BalanceBase.FT.PubCost; d.BalanceBase.FT.PayCost = -d.BalanceBase.FT.PayCost; d.BalanceBase.BalanceOper.OperTime = nowTime; d.BalanceBase.BalanceOper.ID = outpatientManager.Operator.ID; d.BalanceBase.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Reprint; d.BalanceBase.IsDayBalanced = false; d.BalanceBase.DayBalanceOper.ID = ""; d.BalanceBase.DayBalanceOper.OperTime = DateTime.MinValue; ((Balance)d.BalanceBase).CombNO = invoiceSeqNegative; //{9D9D4A6E-84D2-4c07-B6F0-5F2C8DB1DFD7} d.FeeCodeStat.SortID = d.InvoiceSquence; returnValue = outpatientManager.InsertBalanceList(d); if (returnValue <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("插入发票明细冲账信息出错!" + outpatientManager.Err); return(false); } //d.BalanceBase.Invoice.ID = currentInvoiceNO; //d.BalanceBase.TransType = Neusoft.HISFC.Models.Base.TransTypes.Positive; //d.BalanceBase.FT.OwnCost = -d.BalanceBase.FT.OwnCost; //d.BalanceBase.FT.PubCost = -d.BalanceBase.FT.PubCost; //d.BalanceBase.FT.PayCost = -d.BalanceBase.FT.PayCost; //d.BalanceBase.BalanceOper.OperTime = nowTime; //d.BalanceBase.BalanceOper.ID = outpatientManager.Operator.ID; //d.BalanceBase.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Valid; //((Balance)d.BalanceBase).CombNO = invoiceSeqPositive; //d.BalanceBase.FT.TotCost = d.BalanceBase.FT.OwnCost + d.BalanceBase.FT.PayCost + d.BalanceBase.FT.PubCost; //returnValue = outpatientManager.InsertBalanceList(d); //if (returnValue <= 0) //{ // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show("插入新发票明细信息出错!" + outpatientManager.Err); // return false; //} invoiceDetailsPrintTemp.Add(d); } invoiceDetailsPrint.Add(invoiceDetailsPrintTemp); //if (invoiceType == "2") //{ // returnValue = this.feeIntegrate.UpdateOnlyRealInvoiceNO(currentInvoiceNO, currentRealInvoiceNO, ref errText); // if (returnValue <= 0) // { // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show("更新操作员发票失败!" + feeIntegrate.Err); // return false; // } //} //else //{ // returnValue = this.feeIntegrate.UpdateInvoiceNO(currentInvoiceNO, currentRealInvoiceNO, ref errText); // if (returnValue <= 0) // { // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show("更新操作员发票失败!" + feeIntegrate.Err); // return false; // } //} } //处理支付信息 comBalancePays = outpatientManager.QueryBalancePaysByInvoiceSequence(currentBalance.CombNO); if (comBalancePays == null) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("获得患者支付信息出错!" + outpatientManager.Err); return(false); } returnValue = outpatientManager.UpdateCancelTyeByInvoiceSequence("4", currentBalance.CombNO, Neusoft.HISFC.Models.Base.CancelTypes.Reprint); if (returnValue < 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("更新支付方式出错!" + outpatientManager.Err); return(false); } foreach (BalancePay p in comBalancePays) { p.TransType = Neusoft.HISFC.Models.Base.TransTypes.Negative; p.FT.TotCost = -p.FT.TotCost; p.FT.RealCost = -p.FT.RealCost; p.InputOper.OperTime = nowTime; p.InputOper.ID = outpatientManager.Operator.ID; p.InvoiceCombNO = invoiceSeqNegative; p.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Reprint; p.IsChecked = false; p.CheckOper.ID = ""; p.CheckOper.OperTime = DateTime.MinValue; p.BalanceOper.ID = ""; p.BalanceOper.OperTime = DateTime.MinValue; p.IsDayBalanced = false; p.IsAuditing = false; p.AuditingOper.OperTime = DateTime.MinValue; p.AuditingOper.ID = ""; returnValue = outpatientManager.InsertBalancePay(p); if (returnValue <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("插入支付负信息出错!" + outpatientManager.Err); return(false); } //p.TransType = Neusoft.HISFC.Models.Base.TransTypes.Positive; //p.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Valid; //p.FT.TotCost = -p.FT.TotCost; //p.FT.RealCost = -p.FT.RealCost; //p.InvoiceCombNO = invoiceSeqPositive; //p.Invoice.ID = currentInvoiceNO; //returnValue = outpatientManager.InsertBalancePay(p); //if (returnValue <= 0) //{ // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show("插入支付信息出错!" + outpatientManager.Err); // return false; //} } //处理费用明细信息 ArrayList feeItemLists = outpatientManager.QueryFeeItemListsByInvoiceSequence(currentBalance.CombNO); if (feeItemLists == null) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("获得患者费用明细出错!" + outpatientManager.Err); return(false); } returnValue = outpatientManager.UpdateFeeItemListCancelType(currentBalance.CombNO, nowTime, Neusoft.HISFC.Models.Base.CancelTypes.Reprint); if (returnValue <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("作废患者明细出错!" + outpatientManager.Err); return(false); } foreach (FeeItemList f in feeItemLists) { f.TransType = Neusoft.HISFC.Models.Base.TransTypes.Negative; f.FT.OwnCost = -f.FT.OwnCost; f.FT.PayCost = -f.FT.PayCost; f.FT.PubCost = -f.FT.PubCost; f.Item.Qty = -f.Item.Qty; f.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Reprint; f.FeeOper.ID = outpatientManager.Operator.ID; f.FeeOper.OperTime = nowTime; f.CancelOper.OperTime = nowTime; f.InvoiceCombNO = invoiceSeqNegative; returnValue = outpatientManager.InsertFeeItemList(f); if (returnValue <= 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("插入费用明细冲帐信息出错!" + outpatientManager.Err); return(false); } } //foreach (FeeItemList f in feeItemLists) //{ // f.TransType = Neusoft.HISFC.Models.Base.TransTypes.Positive; // f.FT.OwnCost = -f.FT.OwnCost; // f.FT.PayCost = -f.FT.PayCost; // f.FT.PubCost = -f.FT.PubCost; // f.Item.Qty = -f.Item.Qty; // f.CancelType = Neusoft.HISFC.Models.Base.CancelTypes.Valid; // f.FeeOper.ID = outpatientManager.Operator.ID; // f.FeeOper.OperTime = nowTime; // f.CancelOper.OperTime = nowTime; // f.Invoice.ID = currentInvoiceNO; // f.InvoiceCombNO = invoiceSeqPositive; // returnValue = outpatientManager.InsertFeeItemList(f); // if (returnValue <= 0) // { // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show("插入费用明细信息出错!" + outpatientManager.Err); // return false; // } // feeDetailsPrint.Add(f); //} #region 打印发票 //#region 生成赋值后的发票费用明细 //foreach (Balance b in invoicesPrint) //{ // #region 克隆一个费用明细信息列表,因为后面操作需要对列表元素有删除操作. // ArrayList feeItemListsClone = new ArrayList(); // foreach (FeeItemList f in feeItemLists) // { // feeItemListsClone.Add(f.Clone()); // } // #endregion // while (feeItemListsClone.Count > 0) // { // invoicefeeDetailsPrintTemp = new ArrayList(); // string compareItem = b.Invoice.ID; // foreach (FeeItemList f in feeItemListsClone) // { // if (f.Invoice.ID == compareItem) // { // invoicefeeDetailsPrintTemp.Add(f); // } // else // { // break; // } // } // invoicefeeDetailsPrint.Add(invoicefeeDetailsPrintTemp); // foreach (FeeItemList f in invoicefeeDetailsPrintTemp) // { // feeItemListsClone.Remove(f); // } // } //} //#endregion //string invoicePrintDll = this.feeIntegrate.GetControlValue(Neusoft.HISFC.BizProcess.Integrate.Const.INVOICEPRINT, "0"); //if (invoicePrintDll == null || invoicePrintDll == "") //{ // MessageBox.Show("没有设置发票打印参数,不能打印!"); // return false; //} //Neusoft.HISFC.Models.Registration.Register rInfo = new Neusoft.HISFC.Models.Registration.Register(); //Balance invoiceTemp = ((Balance)comBalances[0]); //rInfo.PID.CardNO = invoiceTemp.Patient.PID.CardNO; //rInfo.Pact = invoiceTemp.Patient.Pact.Clone(); //rInfo.Name = invoiceTemp.Patient.Name; //rInfo.SSN = invoiceTemp.Patient.SSN; //#region //ArrayList alPrintInvoicefeeDetails = new ArrayList(); //alPrintInvoicefeeDetails.Add(invoicefeeDetailsPrint); //ArrayList alPrintInvoices = new ArrayList(); //alPrintInvoices.Add(invoiceDetailsPrint); //#endregion //foreach (Balance invo in comBalances) //{ // if (this.pharmacyIntegrate.UpdateDrugRecipeInvoiceN0(invo.Invoice.ID, hsInvoice[invo.Invoice.ID].ToString()) < 0) // { // MessageBox.Show("根据旧发票号更新新发票号出错!"); // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // return false; // } //} //returnValue = this.feeIntegrate.PrintInvoice(invoicePrintDll, rInfo, invoicesPrint, alPrintInvoices, feeDetailsPrint,alPrintInvoicefeeDetails, comBalancePays, false, ref errText); //if (returnValue == -1) //{ // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show(errText); // return false; //} #endregion Neusoft.FrameWork.Management.PublicTrans.Commit(); currentBalance = null; MessageBox.Show("操作成功!"); Clear(); return(true); }