private int MakeInvoice() { if (alFee == null || alFee.Count == 0) { MessageBox.Show("该患者不存在费用!"); return(-1); } listPay.Clear(); ArrayList al = null; Neusoft.HISFC.Models.Base.Employee employee = this.managerIntegrate.GetEmployeeInfo(this.outpatientManager.Operator.ID); if (employee == null) { MessageBox.Show("获取人员信息失败!" + managerIntegrate.Err); return(-1); } string errText = string.Empty; #region 获取发票号 string invoiceNO = string.Empty, realInvoiceNO = string.Empty; Neusoft.FrameWork.Management.PublicTrans.BeginTransaction(); this.feeIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); //获得本次收费起始发票号 int iReturnValue = this.feeIntegrate.GetInvoiceNO(employee, ref invoiceNO, ref realInvoiceNO, ref errText, null); if (iReturnValue == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(errText, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(-1); } Neusoft.FrameWork.Management.PublicTrans.RollBack(); #endregion Dictionary <HISFC.Models.Registration.Register, ArrayList> listInvoice = new Dictionary <Neusoft.HISFC.Models.Registration.Register, ArrayList>(); ArrayList balance = new ArrayList(); Neusoft.HISFC.Models.Registration.Register r = null; //根据每次挂号所生成的费用生成发票 foreach (string key in listFee.Keys) { al = listFee[key]; r = registerIntegrate.GetByClinic(key); if (r == null) { MessageBox.Show("查询患者挂号信息失败!"); return(-1); } balance = Class.Function.MakeInvoice(this.feeIntegrate, r, al, invoiceNO, realInvoiceNO, ref errText); if (balance == null) { return(-1); } listInvoice.Add(r, balance); } Neusoft.FrameWork.Management.PublicTrans.BeginTransaction(); string operID = outpatientManager.Operator.ID; DateTime feeTime = outpatientManager.GetDateTimeFromSysDateTime(); string invoiceUnion = outpatientManager.GetSequence("Fee.OutPatient.InvoiceUnionID"); if (string.IsNullOrEmpty(invoiceUnion)) { errText = "获取发票组号失败!" + outpatientManager.Err; return(-1); } try { Neusoft.HISFC.Models.Registration.Register register = null; ArrayList balancesList = null; ArrayList invoices = null; ArrayList invoiceDetail = null; ArrayList feeList = null; IDictionaryEnumerator ide = listInvoice.GetEnumerator(); while (ide.MoveNext()) { register = ide.Key as Neusoft.HISFC.Models.Registration.Register; balancesList = ide.Value as ArrayList; invoices = balancesList[0] as ArrayList; invoiceDetail = balancesList[1] as ArrayList; feeList = balancesList[2] as ArrayList; //插入发票信息 if (this.InsertInvoices(invoices, register, feeTime, operID, invoiceUnion, ref errText) < 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(errText); return(-1); } //插入发票明细 if (this.InsertInvoiceDetails(invoiceDetail, feeTime, operID, ref errText) < 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(errText); return(-1); } //插入支付方式信息 if (this.InsertInvocePayMode(invoices, feeTime, operID, invoiceUnion, ref errText) < 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(errText); return(-1); } feeList = listFee[register.ID]; //更新费用明细 if (this.UpdateFeeItemList(feeList, ref errText) < 0) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(errText); } } string invoicePrintDll = null; //invoicePrintDll = controlParamIntegrate.GetControlParam<string>(Neusoft.HISFC.BizProcess.Integrate.Const.INVOICEPRINT, false, string.Empty); //if (invoicePrintDll == null || invoicePrintDll == string.Empty) //{ // MessageBox.Show("没有设置发票打印参数,收费请维护!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} invoicePrintDll = controlParamIntegrate.GetControlParam <string>(Neusoft.HISFC.BizProcess.Integrate.Const.NEWINVOICEPRINT, false, string.Empty); if (invoicePrintDll == null || invoicePrintDll == string.Empty) { MessageBox.Show("没有设置发票打印参数,收费请维护!"); } ide.Reset(); while (ide.MoveNext()) { register = ide.Key as HISFC.Models.Registration.Register; balancesList = ide.Value as ArrayList; invoices = balancesList[0] as ArrayList; ArrayList tempal = new ArrayList(); foreach (ArrayList obj in balancesList[1] as ArrayList) { tempal.Add(obj[0]); } invoiceDetail = new ArrayList(); invoiceDetail.Add(tempal); feeList = listFee[register.ID]; this.feeIntegrate.PrintInvoice(invoicePrintDll, register, invoices, invoiceDetail, feeList, listPay[register.ID], false, ref errText); } Neusoft.FrameWork.Management.PublicTrans.Commit(); this.Clear(); } catch (Exception ex) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("打印发票失败!" + ex.Message); return(-1); } return(1); }