Ejemplo n.º 1
0
        /// <summary>
        /// 退费处理
        /// </summary>
        private void RefundmentProcess()
        {
               //delete by heyan 2011.3.22 不是该收费员收的费也可以退费
            //if ( _EmployeeID != Convert.ToInt32( currentInvoice.ChargeUserId ) )
            //{
            //    throw new OperatorException( "该发票不是您收费,需收费员【"+currentInvoice.ChargeUser+"】才能退费!" );
            //}
            //得到新的处方
            List <int> returnedDocPresIdList = new List <int>(); //有退费处理的医生处方ID

            Prescription[] remanentPrescriptions = GetPrescriptionRemanentFromGrid(true, out returnedDocPresIdList);
            if (remanentPrescriptions == null)
            {
                throw new OperatorException("至少需要指定一条需要退费项目的数量!");
            }
            //整理处方,除去0数量和没有明细的处方
            List <Prescription> lstPrescription = new List <Prescription>( );

            for (int i = 0; i < remanentPrescriptions.Length; i++)
            {
                remanentPrescriptions[i].PrescriptionID = 0;
                List <PrescriptionDetail> lstDetail = new List <PrescriptionDetail>( );
                for (int j = 0; j < remanentPrescriptions[i].PresDetails.Length; j++)
                {
                    remanentPrescriptions[i].PresDetails[j].DetailId = 0;
                    if (remanentPrescriptions[i].PresDetails[j].Tolal_Fee != 0)
                    {
                        lstDetail.Add(remanentPrescriptions[i].PresDetails[j]);
                    }
                }
                remanentPrescriptions[i].Modified  = true;
                remanentPrescriptions[i].DocPresId = 0;
                if (lstDetail.Count > 0)
                {
                    remanentPrescriptions[i].PresDetails = lstDetail.ToArray( );
                    lstPrescription.Add(remanentPrescriptions[i]);
                }
            }
            remanentPrescriptions = lstPrescription.ToArray( );
            if (remanentPrescriptions.Length == 0)
            {
                remanentPrescriptions = null;
            }


            ChargeControl chargeController = new ChargeControl(currentPatient, _EmployeeID);

            try
            {
                decimal newcost      = 0;
                decimal newmoneypay  = 0;
                decimal newpos       = 0;
                decimal newfoverpay  = 0;
                decimal newtally     = 0;
                decimal invoiceCount = 0;
                if (chargeController.Refundment(currentInvoice, remanentPrescriptions, returnedDocPresIdList))
                {
                    if (remanentPrescriptions != null)
                    {
                        if (chargeController.SavePrescription(remanentPrescriptions))
                        {
                            if (MessageBox.Show("部分退费需要重新补打发票收据,请确认发票是否已经准备就绪!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                            {
                                MessageBox.Show("用户已取消操作,需要重新收费的处方还未收费,请转到收费窗口继续收费!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                ReturnPatient      = currentPatient;
                                HasPresNeedBalance = true;
                                return;
                            }

                            ChargeInfo[] chargeInfos = chargeController.Budget(remanentPrescriptions);
                            #region 合计结算信息并显示给用户
                            //累计结算信息
                            HIS.MZ_BLL.ChargeInfo totalChargeInfo = new HIS.MZ_BLL.ChargeInfo( );
                            for (int i = 0; i < chargeInfos.Length; i++)
                            {
                                totalChargeInfo.TotalFee   += chargeInfos[i].TotalFee;
                                totalChargeInfo.FavorFee   += chargeInfos[i].FavorFee;
                                totalChargeInfo.SelfFee    += chargeInfos[i].SelfFee;
                                totalChargeInfo.VillageFee += chargeInfos[i].VillageFee;
                            }

                            //向用户展示结算信息
                            FrmChargeInfo frmChargeInfo = new FrmChargeInfo(totalChargeInfo, true);
                            frmChargeInfo.ShowDialog( );

                            chargeController.SetChargeInfoPay(ref chargeInfos, frmChargeInfo.ReturnChargeInfo.VillageFee,
                                                              frmChargeInfo.ReturnChargeInfo.PosFee,
                                                              frmChargeInfo.ReturnChargeInfo.CashFee, frmChargeInfo.ReturnChargeInfo.SelfTally);

                            #endregion
                            Invoice[] invoices;
                            chargeController.Charge(chargeInfos, remanentPrescriptions, out invoices);

                            PrintController.PrintChargeInvoice(invoices);
                            invoiceCount = invoices.Length;
                            for (int i = 0; i < invoices.Length; i++)
                            {
                                newcost     += invoices[i].TotalPay;
                                newmoneypay += invoices[i].CashPay;
                                newpos      += invoices[i].PosPay;
                                newfoverpay += invoices[i].FavorPay;
                                newtally    += invoices[i].VillagePay;
                            }
                        }
                    }

                    decimal returncost     = currentInvoice.TotalPay - newcost;
                    decimal returnmoneypay = currentInvoice.CashPay - newmoneypay;
                    decimal returnpos      = currentInvoice.PosPay - newpos;
                    decimal returnfoverpay = currentInvoice.FavorPay - newfoverpay;
                    decimal returntally    = currentInvoice.VillagePay - newtally;
                    GWMHIS.BussinessLogicLayer.Forms.GwmMessageBox.Show("本次操作完成!\r\n需要退病人金额:" + returncost + "元,其中:" +
                                                                        "\r\n退 现 金:" + returnmoneypay + "元" +
                                                                        "\r\n退 POS  :" + returnpos + "元" +
                                                                        "\r\n退 优 惠:" + returnfoverpay + "元" +
                                                                        "\r\n退 记 账:" + returntally + "元" +
                                                                        "\r\n\r\n新打发票:" + invoiceCount + "张" +
                                                                        "\r\n总 金 额:" + newcost + "元",
                                                                        (new Font("宋体", 15F)), Color.Red, "退费成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("退费失败!\r\n可能的原因;+\r\n" + err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }