示例#1
0
        /// <summary>
        /// 身份变更确认操作
        /// </summary>
        /// <returns></returns>
        protected virtual int ChangePact()
        {
            if (this.IsValid() < 0)
            {
                return(-1);
            }
            Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm("正在处理明细数据……");
            Application.DoEvents();
            Neusoft.FrameWork.Models.NeuObject newObj = new Neusoft.FrameWork.Models.NeuObject();
            Neusoft.FrameWork.Models.NeuObject oldObj = new Neusoft.FrameWork.Models.NeuObject();
            Neusoft.FrameWork.Models.NeuObject obj    = new Neusoft.FrameWork.Models.NeuObject();
            //备份收费药品信息
            ArrayList alDruglistBackUp = new ArrayList();
            //备份收费药品信息
            ArrayList alUndruglistBackUp = new ArrayList();

            obj = this.GetPactUnitByID(this.cmbNewPact.SelectedItem.ID);

            this.medcareInterfaceProxy.SetPactCode(this.cmbNewPact.SelectedItem.ID);
            //Neusoft.FrameWork.Management.Transaction t = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance);

            Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

            Neusoft.HISFC.BizProcess.Integrate.Pharmacy pharmacyIntegrate = new Neusoft.HISFC.BizProcess.Integrate.Pharmacy();
            pharmacyIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);

            this.InpatientManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);
            this.myPactUnit.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);
            this.radtIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);
            this.feeIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);

            newObj.ID     = this.cmbNewPact.SelectedItem.ID;   //1 合同单位代码
            newObj.Name   = this.cmbNewPact.SelectedItem.Name; //2 合同单位名称
            newObj.User01 = obj.ID;                            //3 结算类别代码
            newObj.User02 = obj.Name;                          //4 结算类别名称
            newObj.User03 = this.patientInfo.SSN;              //医疗证号

            oldObj.ID   = this.txtOldPact.Tag.ToString();
            oldObj.Name = this.txtOldPact.Text;


            #region 退费


            #region 处理非药品



            //处理非药品
            if (this.fpUndrug_Sheet1.RowCount > 0)
            {
                for (int i = 0; i < fpUndrug_Sheet1.RowCount; i++)
                {
                    Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList undrugItem    = new Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList();
                    Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList oldUndrugItem = new Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList();
                    if (this.fpUndrug_Sheet1.Rows[i].Tag != null)
                    {
                        undrugItem          = (Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList) this.fpUndrug_Sheet1.Rows[i].Tag;
                        oldUndrugItem       = undrugItem.Clone();
                        undrugItem.ExtFlag2 = "3";//变更标志
                        //退费



                        undrugItem.IsNeedUpdateNoBackQty = true;
                        if (this.feeIntegrate.QuitItem(this.patientInfo, undrugItem) == -1)
                        {
                            Neusoft.FrameWork.Management.PublicTrans.RollBack();
                            Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                            MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                            this.Clear();
                            return(-1);
                        }


                        //收费
                        oldUndrugItem.RecipeNO         = this.InpatientManager.GetUndrugRecipeNO();
                        oldUndrugItem.Patient.Pact.ID  = this.cmbNewPact.SelectedItem.ID;
                        oldUndrugItem.FeeOper.ID       = this.InpatientManager.Operator.ID;
                        oldUndrugItem.FeeOper.OperTime = this.InpatientManager.GetDateTimeFromSysDateTime();
                        //备份非药品信息


                        alUndruglistBackUp.Add(oldUndrugItem);
                        //if (this.feeIntegrate.FeeItem(this.oENewPatientInfo, oldUndrugItem) == -1)
                        //{
                        //    t.RollBack();
                        //    Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                        //    MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                        //    this.Clear();
                        //    return -1;
                        //}
                    }
                    else
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                        MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                        this.Clear();
                        return(-1);
                    }
                }
            }
            #endregion

            #region 处理药品
            //处理药品
            if (this.fpDrug_Sheet1.RowCount > 0)
            {
                for (int i = 0; i < fpDrug_Sheet1.RowCount; i++)
                {
                    Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList medicineItem    = new Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList();
                    Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList oldMedicineItem = new Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList();
                    if (this.fpDrug_Sheet1.Rows[i].Tag != null)
                    {
                        medicineItem          = (Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList) this.fpDrug_Sheet1.Rows[i].Tag;
                        oldMedicineItem       = medicineItem.Clone();
                        medicineItem.ExtFlag2 = "3";//变更标志
                        //退费

                        ////这里是否更改成未摆药的更新发药申请的记录addbyhuazb
                        //if (string.IsNullOrEmpty(medicineItem.ExecOper.ID))
                        //{
                        //    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        //    Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                        //    MessageBox.Show("保存出错出错" + "该患者有药未摆,请通知药房摆药以后再进行变更!");
                        //    this.Clear();
                        //    return -1;
                        //}



                        medicineItem.IsNeedUpdateNoBackQty = true;
                        if (this.feeIntegrate.QuitItem(this.patientInfo, medicineItem) == -1)
                        {
                            Neusoft.FrameWork.Management.PublicTrans.RollBack();
                            Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                            MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                            this.Clear();
                            return(-1);
                        }


                        //收费
                        //存储旧处方号
                        oldMedicineItem.BalanceOper.User01 = oldMedicineItem.RecipeNO;

                        oldMedicineItem.RecipeNO         = this.InpatientManager.GetDrugRecipeNO();
                        oldMedicineItem.Patient.Pact.ID  = this.cmbNewPact.SelectedItem.ID;
                        oldMedicineItem.FeeOper.ID       = this.InpatientManager.Operator.ID;
                        oldMedicineItem.FeeOper.OperTime = this.InpatientManager.GetDateTimeFromSysDateTime();
                        //备份药品信息
                        alDruglistBackUp.Add(oldMedicineItem);
                        //if (this.feeIntegrate.FeeItem(this.oENewPatientInfo, oldMedicineItem) == -1)
                        //{
                        //    t.RollBack();
                        //    Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                        //    MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                        //    this.Clear();
                        //    return -1;
                        //}
                    }
                    else
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                        MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                        this.Clear();
                        return(-1);
                    }
                }
            }
            #endregion
            #endregion


            if (this.radtIntegrate.SetPactShiftData(this.patientInfo, newObj, oldObj) != 0)
            {
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                MessageBox.Show("调用中间层出错");
                this.Clear();
                return(-1);
            }
            //获得更改后得患者信息



            this.oENewPatientInfo = this.radtIntegrate.GetPatientInfomation(this.patientInfo.ID);
            if (this.oENewPatientInfo == null)
            {
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                MessageBox.Show("获得变更后患者信息出错!!", "提示");
                this.Clear();
                return(-1);
            }

            #region 重新收费
            #region 处理非药品


            long returnValue = 0;
            this.medcareInterfaceProxy.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);
            returnValue = this.medcareInterfaceProxy.Connect();
            if (returnValue < 0)
            {
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                this.medcareInterfaceProxy.Rollback();
                //{0C35F3E3-2E72-4ae3-8809-FF3809DA2A16}
                Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                MessageBox.Show("请确保待遇接口存在或正常初始化初始化失败" + this.medcareInterfaceProxy.ErrMsg);
                this.Clear();
                return(-1);
            }
            returnValue = this.medcareInterfaceProxy.GetRegInfoInpatient(oENewPatientInfo);
            if (returnValue < 0)
            {
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                this.medcareInterfaceProxy.Rollback();
                //{0C35F3E3-2E72-4ae3-8809-FF3809DA2A16}
                Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                MessageBox.Show("待遇接口获得患者信息失败" + this.medcareInterfaceProxy.ErrMsg);
                this.Clear();
                return(-1);
            }
            returnValue = this.medcareInterfaceProxy.UploadRegInfoInpatient(oENewPatientInfo);
            if (returnValue < 0)
            {
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                this.medcareInterfaceProxy.Rollback();
                //{0C35F3E3-2E72-4ae3-8809-FF3809DA2A16}
                Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                MessageBox.Show("待遇接口上传住院登记信息失败" + this.medcareInterfaceProxy.ErrMsg);
                this.Clear();
                return(-1);
            }

            //处理非药品
            if (alUndruglistBackUp.Count > 0)
            {
                for (int i = 0; i < alUndruglistBackUp.Count; i++)
                {
                    Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList oldUndrugItem = new Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList();
                    oldUndrugItem = (Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList)alUndruglistBackUp[i];
                    if (this.feeIntegrate.FeeItem(this.oENewPatientInfo, oldUndrugItem) == -1)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        this.medcareInterfaceProxy.Rollback();
                        Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                        MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                        this.Clear();
                        return(-1);
                    }
                }
            }
            #endregion

            #region 处理药品
            //处理药品
            if (alDruglistBackUp.Count > 0)
            {
                for (int i = 0; i < alDruglistBackUp.Count; i++)
                {
                    Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList oldMedicineItem = new Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList();
                    oldMedicineItem = (Neusoft.HISFC.Models.Fee.Inpatient.FeeItemList)alDruglistBackUp[i];
                    if (oldMedicineItem != null)
                    {
                        if (this.feeIntegrate.FeeItem(this.oENewPatientInfo, oldMedicineItem.Clone()) == -1)
                        {
                            Neusoft.FrameWork.Management.PublicTrans.RollBack();
                            this.medcareInterfaceProxy.Rollback();
                            Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                            MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                            this.Clear();
                            return(-1);
                        }
                        //这里收费完已经发药的senddrug_flag未更新。addbyhuazb

                        if (this.InpatientManager.UpdateMedItemExecInfo(oldMedicineItem.RecipeNO, oldMedicineItem.SequenceNO
                                                                        , oldMedicineItem.UpdateSequence, oldMedicineItem.SendSequence, (int)oldMedicineItem.PayType, oldMedicineItem.StockOper.Dept.ID,
                                                                        oldMedicineItem.ExecOper.ID, oldMedicineItem.ExecOper.OperTime) == -1)
                        {
                            Neusoft.FrameWork.Management.PublicTrans.RollBack();
                            this.medcareInterfaceProxy.Rollback();
                            Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                            MessageBox.Show("调用中间层出错" + this.feeIntegrate.Err);
                            this.Clear();
                            return(-1);
                        }
                        //更新处方号
                        if (pharmacyIntegrate.UpdateApplyOutRecipe(oldMedicineItem.BalanceOper.User01, oldMedicineItem.SequenceNO, oldMedicineItem.RecipeNO, oldMedicineItem.SequenceNO) == -1)
                        {
                            Neusoft.FrameWork.Management.PublicTrans.RollBack();
                            Neusoft.FrameWork.Management.PublicTrans.RollBack();
                            Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                            MessageBox.Show("更新药品申请表处方号信息发生错误!" + pharmacyIntegrate.Err);
                            this.Clear();
                            return(-1);
                        }
                    }
                }
            }
            #endregion
            #endregion


            Neusoft.FrameWork.Management.PublicTrans.Commit();
            this.medcareInterfaceProxy.Commit();
            MessageBox.Show(Neusoft.FrameWork.Management.Language.Msg("变更成功"));
            Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
            //重新显示介面
            this.SetpatientInfo(this.oENewPatientInfo);
            //重新显示费用明细
            this.DisplayDetail(this.oENewPatientInfo.ID);

            return(1);
        }
示例#2
0
        /// <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);
        }