Ejemplo n.º 1
0
        bool splitUnit_CostChanged(string feeStat, decimal orgCost, decimal newCost, ref Neusoft.HISFC.Models.Base.FT ft, ref decimal CTFee, ref decimal MRIFee, ref decimal SXFee, ref decimal SYFee)
        {
            ucSplitUnit tempLastSpitUnit = new ucSplitUnit();

            foreach (Control crtl in this.plSplitUnits.Controls)
            {
                if (((ucSplitUnit)crtl).IsLast)
                {
                    tempLastSpitUnit = (ucSplitUnit)crtl;
                    ArrayList detailsTemp = ((ucSplitUnit)crtl).InvoiceDetails;
                    Neusoft.HISFC.Models.Fee.Outpatient.Balance invoiceTemp = ((ucSplitUnit)crtl).Invoice;
                    foreach (Neusoft.HISFC.Models.Fee.Outpatient.BalanceList detail in detailsTemp)
                    {
                        if (detail.FeeCodeStat.ID == feeStat)
                        {
                            if (detail.BalanceBase.FT.TotCost + orgCost < newCost)
                            {
                                MessageBox.Show("分票的金额大于可分金额!");

                                return(false);
                            }
                            else
                            {
                                decimal errCost = newCost - orgCost;

                                if (feeStat == this.STATCODEJC)//检查项目
                                {
                                    detail.CTFee  += CTFee;
                                    detail.MRIFee += MRIFee;
                                    MRIFee         = 0;
                                    CTFee          = 0;
                                }
                                if (feeStat == this.STATCODEZL)//检查项目
                                {
                                    detail.SXFee += SXFee;
                                    detail.SYFee += SYFee;
                                    SXFee         = 0;
                                    SYFee         = 0;
                                }

                                detail.BalanceBase.FT.TotCost = detail.BalanceBase.FT.TotCost - errCost;
                                detail.BalanceBase.FT.OwnCost = detail.BalanceBase.FT.OwnCost - errCost;

                                invoiceTemp.FT.TotCost = invoiceTemp.FT.TotCost - errCost;
                                invoiceTemp.FT.OwnCost = invoiceTemp.FT.OwnCost - errCost;

                                if (feeStat == this.STATCODEJC)//检查
                                {
                                    if ((detail.BalanceBase.FT.TotCost) < detail.CTFee + detail.MRIFee)
                                    {
                                        decimal tempCost   = 0;
                                        decimal errCostOut = detail.CTFee + detail.MRIFee - detail.BalanceBase.FT.TotCost;
                                        tempCost = errCost - detail.CTFee;
                                        if (tempCost <= 0)
                                        {
                                            CTFee        = tempCost;
                                            detail.CTFee = detail.CTFee - tempCost;
                                            MRIFee       = 0;
                                        }
                                        else
                                        {
                                            CTFee         = detail.CTFee;
                                            detail.CTFee  = 0;
                                            MRIFee        = tempCost - detail.CTFee;
                                            detail.MRIFee = detail.MRIFee - MRIFee;
                                        }
                                    }
                                }
                                if (feeStat == this.STATCODEZL)//检查
                                {
                                    if ((detail.BalanceBase.FT.TotCost) < detail.SYFee + detail.SXFee)
                                    {
                                        decimal tempCost   = 0;
                                        decimal errCostOut = detail.SYFee + detail.SXFee - detail.BalanceBase.FT.TotCost;
                                        tempCost = errCost - detail.SYFee;
                                        if (tempCost <= 0)
                                        {
                                            SYFee = tempCost;
                                            SXFee = 0;
                                        }
                                        else
                                        {
                                            SYFee = detail.SYFee;
                                            SXFee = tempCost - detail.SYFee;
                                        }
                                    }
                                }
                            }

                            tempLastSpitUnit.Invoice        = invoiceTemp;
                            tempLastSpitUnit.InvoiceDetails = detailsTemp;
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 默认分发票
        /// </summary>
        /// <param name="count">分票的张数</param>
        /// <param name="splitFlag">类型 1自动 0 自定义</param>
        public void AddInvoiceUnits(int count, string splitFlag)
        {
            //清空控件
            ClearInvoicUnits();

            int      xPoint = 0, yPoint = 0;
            DateTime dtTempPrint = this.invoice.PrintTime;

            for (int i = 0; i < count; i++)
            {
                splitUnit = new ucSplitUnit();

                if (Math.IEEERemainder(i, 2) == 0)
                {
                    xPoint = 28;
                }
                else
                {
                    xPoint = 16 * 2 + splitUnit.Width + 25;
                }

                yPoint = 14 + (i / 2) * (16 + splitUnit.Height);
                if (i > 0)
                {
                    dtTempPrint = dtTempPrint.AddDays(this.days);
                }
                splitUnit.Location        = new System.Drawing.Point(xPoint, yPoint);
                splitUnit.Name            = "splitUnit" + i.ToString();
                splitUnit.InvoiceDate     = dtTempPrint;
                splitUnit.TabIndex        = i + 1;
                splitUnit.CostChanged    += new ucSplitUnit.ChangeCost(splitUnit_CostChanged);
                splitUnit.ModifyFinished += new ucSplitUnit.ChangeFocus(splitUnit_ModifyFinished);
                if (splitFlag == "1")//自动分发票
                {
                    splitUnit.IsLast = true;
                }
                else
                {
                    if (i == count - 1)
                    {
                        splitUnit.IsLast = true;
                    }
                    else
                    {
                        splitUnit.IsLast = false;
                    }
                }

                this.plSplitUnits.Controls.Add(splitUnit);
            }

            this.ucInvoicePreviewGF1.InvoiceType = invoiceType;
            ArrayList alTempInvoice = new ArrayList();

            alTempInvoice.Add(invoice);
            ArrayList alTempInvoiceAndDetails = new ArrayList();

            alTempInvoiceAndDetails.Add(alTempInvoice);
            ArrayList tempInvoiceDetails    = new ArrayList();
            ArrayList tempInvoiceDetailsTow = new ArrayList();

            tempInvoiceDetailsTow.Add(invoiceDetails);
            tempInvoiceDetails.Add(tempInvoiceDetailsTow);

            alTempInvoiceAndDetails.Add(tempInvoiceDetails);
            this.ucInvoicePreviewGF1.InvoiceAndDetails = alTempInvoiceAndDetails;

            ArrayList tempSplit = new ArrayList();
            decimal   errorOwnCost = 0, errorPubCost = 0, errorTotCost = 0, errorPayCost = 0; //各项金额分票时得误差
            decimal   errCTFee = 0, errMRIFee = 0, errSXFee = 0, errSYFee = 0;                //CT费等误差
            decimal   sumOwnCost = 0, sumPubCost = 0, sumTotCost = 0, sumPayCost = 0;         //根据发票明细汇总得发票金额

            Neusoft.HISFC.Models.Fee.Outpatient.Balance tempInvoice = null;

            Neusoft.HISFC.Models.Fee.Outpatient.BalanceList detailTemp = null;
            ArrayList invoiceDetailsSplit = new ArrayList();
            ArrayList invoicesSplit       = new ArrayList();
            int       iReturn             = 0;

            for (int i = 0; i < count; i++)
            {
                ArrayList invoiceDetailsToInvoice = new ArrayList();
                string    beginTempInvoiceNo      = "";
                string    beginTempRealInvoiceNo  = "";
                string    errText = "";

                if (invoiceNoType == "2")//普通模式需要Trans支持
                {
                    Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();
                    this.feeIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);

                    iReturn = this.feeIntegrate.GetNextInvoiceNO(invoiceNoType, beginInvoiceNo, beginRealInvoiceNo, ref beginTempInvoiceNo, ref beginTempRealInvoiceNo, i + 1, ref errText);
                    if (iReturn < 0)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        MessageBox.Show(errText);

                        this.plSplitUnits.Controls.Clear();

                        return;
                    }

                    Neusoft.FrameWork.Management.PublicTrans.RollBack();//因为此时不一定插入数据库,所以回滚,保持发票不跳号
                }
                else
                {
                    iReturn = this.feeIntegrate.GetNextInvoiceNO(this.invoiceNoType, beginInvoiceNo, this.beginRealInvoiceNo, ref beginTempInvoiceNo, ref beginTempRealInvoiceNo, i, ref errText);
                    if (iReturn < 0)
                    {
                        MessageBox.Show(errText);
                        return;
                    }
                }
                foreach (Neusoft.HISFC.Models.Fee.Outpatient.BalanceList detail in invoiceDetails)
                {
                    detailTemp = detail.Clone();

                    detailTemp.BalanceBase.FT.TotCost = Neusoft.FrameWork.Public.String.FormatNumber((detail.BalanceBase.FT.TotCost / (decimal)count), 2);
                    detailTemp.BalanceBase.FT.PayCost = Neusoft.FrameWork.Public.String.FormatNumber((detail.BalanceBase.FT.PayCost / (decimal)count), 2);
                    detailTemp.BalanceBase.FT.OwnCost = Neusoft.FrameWork.Public.String.FormatNumber((detail.BalanceBase.FT.OwnCost / (decimal)count), 2);
                    detailTemp.BalanceBase.FT.PubCost = Neusoft.FrameWork.Public.String.FormatNumber((detail.BalanceBase.FT.PubCost / (decimal)count), 2);
                    detailTemp.CTFee  = Neusoft.FrameWork.Public.String.FormatNumber((detail.CTFee / (decimal)count), 2);
                    detailTemp.MRIFee = Neusoft.FrameWork.Public.String.FormatNumber((detail.MRIFee / (decimal)count), 2);
                    detailTemp.SXFee  = Neusoft.FrameWork.Public.String.FormatNumber((detail.SXFee / (decimal)count), 2);
                    detailTemp.SYFee  = Neusoft.FrameWork.Public.String.FormatNumber((detail.SYFee / (decimal)count), 2);
                    detailTemp.BalanceBase.Invoice.ID = beginTempInvoiceNo;

                    errorOwnCost = detail.BalanceBase.FT.OwnCost - detailTemp.BalanceBase.FT.OwnCost * count;
                    errorPubCost = detail.BalanceBase.FT.PubCost - detailTemp.BalanceBase.FT.PubCost * count;
                    errorPayCost = detail.BalanceBase.FT.PayCost - detailTemp.BalanceBase.FT.PayCost * count;
                    errorTotCost = detail.BalanceBase.FT.TotCost - detailTemp.BalanceBase.FT.TotCost * count;
                    errCTFee     = detail.CTFee - detailTemp.CTFee * count;
                    errMRIFee    = detail.MRIFee - detailTemp.MRIFee * count;
                    errSXFee     = detail.SXFee - detailTemp.SXFee * count;
                    errSYFee     = detail.SYFee - detailTemp.SYFee * count;

                    if (i == 0)
                    {
                        detailTemp.BalanceBase.FT.TotCost = detailTemp.BalanceBase.FT.TotCost + errorTotCost;
                        detailTemp.BalanceBase.FT.PayCost = detailTemp.BalanceBase.FT.PayCost + errorPayCost;
                        detailTemp.BalanceBase.FT.OwnCost = detailTemp.BalanceBase.FT.OwnCost + errorOwnCost;
                        detailTemp.BalanceBase.FT.PubCost = detailTemp.BalanceBase.FT.PubCost + errorPubCost;

                        detailTemp.CTFee  += errCTFee;
                        detailTemp.MRIFee += errMRIFee;
                        detailTemp.SXFee  += errSXFee;
                        detailTemp.SYFee  += errSYFee;
                    }

                    invoiceDetailsToInvoice.Add(detailTemp);
                }

                invoiceDetailsSplit.Add(invoiceDetailsToInvoice);
            }
            for (int i = 0; i < count; i++)
            {
                tempInvoice = invoice.Clone();

                string beginTempInvoiceNo     = "";
                string beginTempRealInvoiceNo = "";
                string errText = "";

                if (invoiceNoType == "2")//普通模式需要Trans支持
                {
                    Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();
                    this.feeIntegrate.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);

                    iReturn = this.feeIntegrate.GetNextInvoiceNO(invoiceNoType, beginInvoiceNo, this.beginRealInvoiceNo, ref beginTempInvoiceNo, ref beginTempRealInvoiceNo, i + 1, ref errText);
                    if (iReturn < 0)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        MessageBox.Show(errText);

                        this.plSplitUnits.Controls.Clear();

                        return;
                    }

                    beginTempRealInvoiceNo = (Neusoft.FrameWork.Function.NConvert.ToInt32(beginTempRealInvoiceNo) - 1).ToString();

                    Neusoft.FrameWork.Management.PublicTrans.RollBack();//因为此时不一定插入数据库,所以回滚,保持发票不跳号
                }
                else
                {
                    iReturn = this.feeIntegrate.GetNextInvoiceNO(this.invoiceNoType, beginInvoiceNo, this.beginRealInvoiceNo, ref beginTempInvoiceNo, ref beginTempRealInvoiceNo, i, ref errText);
                    if (iReturn < 0)
                    {
                        MessageBox.Show(errText);
                        return;
                    }
                }
                //重新计算金额
                ArrayList invoiceDetailsTemp = invoiceDetailsSplit[i] as ArrayList;
                foreach (Neusoft.HISFC.Models.Fee.Outpatient.BalanceList detail in invoiceDetailsTemp)
                {
                    sumOwnCost += detail.BalanceBase.FT.OwnCost;
                    sumPubCost += detail.BalanceBase.FT.PubCost;
                    sumPayCost += detail.BalanceBase.FT.PayCost;
                    sumTotCost += detail.BalanceBase.FT.TotCost;
                }

                tempInvoice.FT.TotCost       = sumTotCost;
                tempInvoice.FT.PayCost       = sumPayCost;
                tempInvoice.FT.OwnCost       = sumOwnCost;
                tempInvoice.FT.PubCost       = sumPubCost;
                tempInvoice.Invoice.ID       = beginTempInvoiceNo;
                tempInvoice.PrintedInvoiceNO = beginTempRealInvoiceNo;

                sumTotCost = 0;
                sumPayCost = 0;
                sumOwnCost = 0;
                sumPubCost = 0;

                invoicesSplit.Add(tempInvoice);
            }
            //添加信息到控件.
            for (int i = 0; i < count; i++)
            {
                try
                {
                    ((ucSplitUnit)plSplitUnits.Controls[i]).Invoice        = invoicesSplit[i] as Neusoft.HISFC.Models.Fee.Outpatient.Balance;
                    ((ucSplitUnit)plSplitUnits.Controls[i]).InvoiceDetails = invoiceDetailsSplit[i] as ArrayList;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }