/// <summary>
        /// 交款
        /// </summary>
        /// <param name="userId">操作员ID(EmployeeId)</param>
        public static bool HandInAccount(int userId, PrivyAccountBook accountBook)
        {
            string strblankoutInvoices = "";

            foreach (string invoiceNum in accountBook.ChargeInvoiceInfo.Useless)
            {
                strblankoutInvoices = strblankoutInvoices + invoiceNum + "|";
            }
            if (strblankoutInvoices.Trim( ) != "")
            {
                strblankoutInvoices = strblankoutInvoices.Remove(strblankoutInvoices.Length - 1, 1);
            }

            MSAccessDb.BeginTrans( );

            try
            {
                HIS.Model.MZ_Account new_mz_account = new HIS.Model.MZ_Account( );
                new_mz_account.AccountCode = userId.ToString( );
                new_mz_account.AccountDate = DateTime.Now;
                new_mz_account.Total_Fee   = accountBook.InvoiceItemSumTotal;
                new_mz_account.Cash_Fee    = 0;
                new_mz_account.POS_Fee     = 0;
                new_mz_account.BlankOut    = strblankoutInvoices;
                new_mz_account.AccountID   = MSAccessDb.GetMaxID("MZ_ACCOUNT", Tables.mz_account.ACCOUNTID);
                //新增账单
                MSAccessDb.InsertRecord(new_mz_account, Tables.mz_account.ACCOUNTID);
                //当前对象ID赋值
                int accountBookId = new_mz_account.AccountID;
                //更新结算表,置账单号
                List <MZ_CostMaster> list_costmaster = MSAccessDb.GetListArray <MZ_CostMaster>("MZ_COSTMASTER", " RECORD_FLAG<>9 and ACCOUNTID=0 and  CHARGECODE='" + userId + "'");
                if (list_costmaster.Count == 0)
                {
                    throw new Exception("没有科目可以交账!");
                }
                for (int i = 0; i < list_costmaster.Count; i++)
                {
                    list_costmaster[i].AccountID = accountBookId;
                    MSAccessDb.UpdateRecord(list_costmaster[i]);
                }
                MSAccessDb.CommitTrans( );
                return(true);
            }

            catch (Exception err)
            {
                MSAccessDb.RollbackTrans( );
                throw new Exception("交款处理发生错误!");
            }
        }
        /// <summary>
        /// 获取个人账单
        /// </summary>
        /// <param name="TollCollectorId">收费员ID</param>
        /// <param name="AccountBookId">账单ID</param>
        /// <param name="tbInvoiceList">发票清单</param>
        /// <param name="tbInvoiceDetailList">发票明细列表</param>
        /// <returns></returns>
        public static PrivyAccountBook GetPrivyAccountBook(int TollCollectorId, int AccountBookId,
                                                           DataTable tbAllInvoiceList, DataTable tbAllInvoiceDetailList, DataTable tbAccountList)
        {
            DataTable tbInvoiceList = tbAllInvoiceList.Clone();

            DataRow[] drsInvoiceList = tbAllInvoiceList.Select("AccountId=" + AccountBookId);
            foreach (DataRow dr in drsInvoiceList)
            {
                tbInvoiceList.Rows.Add(dr.ItemArray);
            }

            DataTable tbInvoiceDetailList = tbAllInvoiceDetailList.Clone( );

            DataRow[] drsInvoiceDetailList = tbAllInvoiceDetailList.Select("AccountId=" + AccountBookId);
            foreach (DataRow dr in drsInvoiceDetailList)
            {
                tbInvoiceDetailList.Rows.Add(dr.ItemArray);
            }

            DataRow[] drAccounts = tbAccountList.Select("ACCOUNTID=" + AccountBookId);
            DataRow   drAccount  = null;

            if (drAccounts.Length != 0)
            {
                drAccount = drAccounts[0];
            }

            PrivyAccountBook accountBook = new PrivyAccountBook( );

            if (drAccount != null)
            {
                accountBook.AccountBookDate   = Convert.ToDateTime(drAccount["AccountDate"]);
                accountBook.AccountId         = Convert.ToInt32(drAccount["AccountId"]);
                accountBook.TollCollectorName = DataReader.GetEmployeeNameById(TollCollectorId);
            }
            else
            {
                accountBook.AccountId = 0;
            }
            #region 发票科目明细列表
            Hashtable htInvoiceItems = new Hashtable( );
            for (int i = 0; i < tbInvoiceDetailList.Rows.Count; i++)
            {
                string      mzfp_code   = tbInvoiceDetailList.Rows[i]["mzfp_code"].ToString( ).Trim( );
                string      mzfp_name   = tbInvoiceDetailList.Rows[i]["item_name"].ToString( ).Trim( );
                decimal     item_fee    = Convert.ToDecimal(tbInvoiceDetailList.Rows[i]["total_fee"]);
                InvoiceItem invoiceItem = new InvoiceItem( );
                invoiceItem.ItemCode = mzfp_code;
                invoiceItem.ItemName = mzfp_name;
                invoiceItem.Cost     = item_fee;

                if (htInvoiceItems.ContainsKey(invoiceItem.ItemCode))
                {
                    InvoiceItem _invoiceItem = (InvoiceItem)htInvoiceItems[invoiceItem.ItemCode];
                    htInvoiceItems.Remove(invoiceItem.ItemCode);
                    _invoiceItem.Cost = _invoiceItem.Cost + invoiceItem.Cost;
                    htInvoiceItems.Add(_invoiceItem.ItemCode, _invoiceItem);
                }
                else
                {
                    htInvoiceItems.Add(invoiceItem.ItemCode, invoiceItem);
                }
                accountBook.InvoiceItemSumTotal += invoiceItem.Cost;
            }
            accountBook.InvoiceItem = new InvoiceItem[htInvoiceItems.Count];
            int invoiceItemIndex = 0;
            foreach (object obj in htInvoiceItems)
            {
                accountBook.InvoiceItem[invoiceItemIndex] = (InvoiceItem)((DictionaryEntry)obj).Value;
                invoiceItemIndex++;
            }
            #endregion
            //收费票据信息
            AccountBillInfo chargeBillInfo = GetBillInfo(OPDOperationType.门诊收费, tbInvoiceList);
            chargeBillInfo.ChargeName     = DataReader.GetEmployeeNameById(TollCollectorId);
            accountBook.ChargeInvoiceInfo = chargeBillInfo;
            //挂号票据信息
            AccountBillInfo registerBillInfo = GetBillInfo(OPDOperationType.门诊挂号, tbInvoiceList);
            registerBillInfo.ChargeName     = chargeBillInfo.ChargeName;
            accountBook.RegisterInvoiceInfo = registerBillInfo;
            //优惠部分
            accountBook.FavorPart = GetFavorPart(tbInvoiceList);
            //现金部分
            accountBook.CashPart = GetCashPart(tbInvoiceList, tbInvoiceDetailList);
            //记账部分
            accountBook.TallyPart = GetTallyPart(tbInvoiceList);

            return(accountBook);
        }
        /// <summary>
        /// 汇总个人账单
        /// </summary>
        /// <param name="Books"></param>
        /// <returns></returns>
        public static PrivyAccountBook CollectPrivyAccountBook(List <PrivyAccountBook> Books)
        {
            PrivyAccountBook totalBook        = new PrivyAccountBook( );
            AccountBillInfo  chargeBillinfo   = new AccountBillInfo( );
            AccountBillInfo  registerBillinfo = new AccountBillInfo( );
            FundPart         cashPart         = new FundPart( );
            FundPart         favorPart        = new FundPart( );
            FundPart         tallyPart        = new FundPart( );
            Hashtable        htInvoiceItem    = new Hashtable( );

            foreach (PrivyAccountBook book in Books)
            {
                totalBook.InvoiceItemSumTotal += book.InvoiceItemSumTotal;

                #region 合并收费票据部分
                chargeBillinfo.Count += book.ChargeInvoiceInfo.Count;
                if ((chargeBillinfo.StartNumber == "" || chargeBillinfo.StartNumber == null) && book.ChargeInvoiceInfo.StartNumber != "")
                {
                    chargeBillinfo.StartNumber = book.ChargeInvoiceInfo.StartNumber;
                }
                if (book.ChargeInvoiceInfo.EndNumber != "")
                {
                    chargeBillinfo.EndNumber = book.ChargeInvoiceInfo.EndNumber;
                }

                chargeBillinfo.RefundCount += book.ChargeInvoiceInfo.RefundCount;
                chargeBillinfo.RefundMoney += book.ChargeInvoiceInfo.RefundMoney;
                chargeBillinfo.ChargeName   = book.ChargeInvoiceInfo.ChargeName;
                List <Invoice> lstChargeInvoice = new List <Invoice>( );
                if (chargeBillinfo.InvoiceList != null)
                {
                    lstChargeInvoice = chargeBillinfo.InvoiceList.ToList( );
                }
                if (book.ChargeInvoiceInfo.InvoiceList != null)
                {
                    for (int i = 0; i < book.ChargeInvoiceInfo.InvoiceList.Length; i++)
                    {
                        lstChargeInvoice.Add(book.ChargeInvoiceInfo.InvoiceList[i]);
                    }
                }
                chargeBillinfo.InvoiceList = lstChargeInvoice.ToArray( );
                #endregion

                #region 合并挂号票据部分
                registerBillinfo.Count += book.RegisterInvoiceInfo.Count;
                if ((registerBillinfo.StartNumber == "" || registerBillinfo.StartNumber == null) && book.RegisterInvoiceInfo.StartNumber != "")
                {
                    registerBillinfo.StartNumber = book.RegisterInvoiceInfo.StartNumber;
                }
                if (book.RegisterInvoiceInfo.EndNumber != "")
                {
                    registerBillinfo.EndNumber = book.RegisterInvoiceInfo.EndNumber;
                }

                registerBillinfo.RefundCount += book.RegisterInvoiceInfo.RefundCount;
                registerBillinfo.RefundMoney += book.RegisterInvoiceInfo.RefundMoney;
                registerBillinfo.ChargeName   = book.RegisterInvoiceInfo.ChargeName;
                List <Invoice> lstRegInvoice = new List <Invoice>( );
                if (registerBillinfo.InvoiceList != null)
                {
                    lstRegInvoice = registerBillinfo.InvoiceList.ToList( );
                }
                if (book.RegisterInvoiceInfo.InvoiceList != null)
                {
                    for (int i = 0; i < book.RegisterInvoiceInfo.InvoiceList.Length; i++)
                    {
                        lstRegInvoice.Add(book.RegisterInvoiceInfo.InvoiceList[i]);
                    }
                }
                registerBillinfo.InvoiceList = lstRegInvoice.ToArray( );
                #endregion

                #region 合并发票科目部分
                for (int i = 0; i < book.InvoiceItem.Length; i++)
                {
                    if (htInvoiceItem.ContainsKey(book.InvoiceItem[i].ItemCode))
                    {
                        InvoiceItem invoiceItem = (InvoiceItem)htInvoiceItem[book.InvoiceItem[i].ItemCode];
                        invoiceItem.Cost += book.InvoiceItem[i].Cost;
                        htInvoiceItem.Remove(book.InvoiceItem[i].ItemCode);
                        htInvoiceItem.Add(invoiceItem.ItemCode, invoiceItem);
                    }
                    else
                    {
                        htInvoiceItem.Add(book.InvoiceItem[i].ItemCode, book.InvoiceItem[i]);
                    }
                }
                #endregion

                #region 合并现金部分
                cashPart.TotalMoney += book.CashPart.TotalMoney;
                if (cashPart.Details == null)
                {
                    cashPart.Details = new FundInfo[3];
                }
                for (int i = 0; i < book.CashPart.Details.Length; i++)
                {
                    cashPart.Details[i].BillCount += book.CashPart.Details[i].BillCount;
                    cashPart.Details[i].Money     += book.CashPart.Details[i].Money;
                    cashPart.Details[i].PayCode    = book.CashPart.Details[i].PayCode;
                    cashPart.Details[i].PayName    = book.CashPart.Details[i].PayName;
                }
                #endregion

                #region 合并记账部分
                tallyPart.TotalMoney += book.TallyPart.TotalMoney;
                if (tallyPart.Details == null)
                {
                    tallyPart.Details = new FundInfo[book.TallyPart.Details.Length];
                }

                for (int i = 0; i < book.TallyPart.Details.Length; i++)
                {
                    tallyPart.Details[i].BillCount += book.TallyPart.Details[i].BillCount;
                    tallyPart.Details[i].Money     += book.TallyPart.Details[i].Money;
                    tallyPart.Details[i].PayCode    = book.TallyPart.Details[i].PayCode;
                    tallyPart.Details[i].PayName    = book.TallyPart.Details[i].PayName;
                }
                #endregion

                //合并优惠部分
                favorPart.TotalMoney += book.FavorPart.TotalMoney;
            }

            totalBook.ChargeInvoiceInfo   = chargeBillinfo;
            totalBook.RegisterInvoiceInfo = registerBillinfo;
            totalBook.CashPart            = cashPart;
            totalBook.TallyPart           = tallyPart;
            totalBook.FavorPart           = favorPart;

            totalBook.InvoiceItem = new InvoiceItem[htInvoiceItem.Count];
            int count = 0;
            foreach (object obj in htInvoiceItem)
            {
                totalBook.InvoiceItem[count] = (InvoiceItem)((DictionaryEntry)obj).Value;
                count++;
            }

            return(totalBook);
        }
示例#4
0
        /// <summary>
        /// 打印个人交款表
        /// </summary>
        /// <param name="accountBook"></param>
        public static void PrintAccountBook(PrivyAccountBook accountBook)
        {
            grproLib.GridppReport reportPrinter = new grproLib.GridppReport( );


            reportPrinter.LoadFromFile(accountbookTemplatePath);


            reportPrinter.Title = "门诊个人交款表";
            try
            {
                //传入参数
                reportPrinter.ParameterByName("医院名称").AsString = "" + "每日交费清单";
                reportPrinter.ParameterByName("交款人").AsString  = accountBook.TollCollectorName;
                reportPrinter.ParameterByName("交款时间").AsString = accountBook.AccountBookDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
                //传入交款科目
                for (int i = 0; i < accountBook.InvoiceItem.Length; i++)
                {
                    try
                    {
                        reportPrinter.ParameterByName(accountBook.InvoiceItem[i].ItemName.Trim( )).AsString = accountBook.InvoiceItem[i].Cost.ToString( );
                    }
                    catch
                    {
                        MessageBox.Show("没有找到参数:" + accountBook.InvoiceItem[i].ItemName + ",请确认模板中有该参数!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }
                }
                reportPrinter.ParameterByName("发票科目合计").AsString = accountBook.InvoiceItemSumTotal.ToString( );

                reportPrinter.ParameterByName("收费发票开始号").AsString = accountBook.ChargeInvoiceInfo.StartNumber;
                reportPrinter.ParameterByName("收费发票结束号").AsString = accountBook.ChargeInvoiceInfo.EndNumber;
                reportPrinter.ParameterByName("收费发票张数").AsString  = accountBook.ChargeInvoiceInfo.Count.ToString( );
                reportPrinter.ParameterByName("收费退费张数").AsString  = accountBook.ChargeInvoiceInfo.RefundCount.ToString( );
                reportPrinter.ParameterByName("收费退费金额").AsString  = accountBook.ChargeInvoiceInfo.RefundMoney.ToString( );

                reportPrinter.ParameterByName("挂号发票开始号").AsString = accountBook.RegisterInvoiceInfo.StartNumber;
                reportPrinter.ParameterByName("挂号发票结束号").AsString = accountBook.RegisterInvoiceInfo.EndNumber;
                reportPrinter.ParameterByName("挂号发票张数").AsString  = accountBook.RegisterInvoiceInfo.Count.ToString( );
                reportPrinter.ParameterByName("挂号退费张数").AsString  = accountBook.RegisterInvoiceInfo.RefundCount.ToString( );
                reportPrinter.ParameterByName("挂号退费金额").AsString  = accountBook.RegisterInvoiceInfo.RefundMoney.ToString( );
                //按病人类型记账部分
                int tallyCount = 0;
                for (int i = 0; i < accountBook.TallyPart.Details.Length; i++)
                {
                    reportPrinter.ParameterByName(accountBook.TallyPart.Details[i].PayName).AsString         = accountBook.TallyPart.Details[i].Money.ToString( );
                    reportPrinter.ParameterByName(accountBook.TallyPart.Details[i].PayName + "_张数").AsString = accountBook.TallyPart.Details[i].BillCount.ToString( );
                    tallyCount = tallyCount + accountBook.TallyPart.Details[i].BillCount;
                }
                reportPrinter.ParameterByName("记账合计").AsString   = accountBook.TallyPart.TotalMoney.ToString( );
                reportPrinter.ParameterByName("记账合计张数").AsString = tallyCount.ToString( );

                reportPrinter.ParameterByName("优惠金额").AsString = accountBook.FavorPart.TotalMoney.ToString( );
                //现金部分
                reportPrinter.ParameterByName("实收现金").AsString = accountBook.CashPart.TotalMoney.ToString( );
                reportPrinter.ParameterByName("挂号现金").AsString = accountBook.CashPart.Details[1].Money.ToString( );
                reportPrinter.ParameterByName("挂号诊金").AsString = accountBook.CashPart.Details[2].Money.ToString( );
                reportPrinter.ParameterByName("处方收费").AsString = accountBook.CashPart.Details[0].Money.ToString( );

                reportPrinter.ParameterByName("小写合计").AsString = accountBook.InvoiceItemSumTotal.ToString( );
                reportPrinter.ParameterByName("大写合计").AsString = "";  //HIS.SYSTEM.PubicBaseClasses.Money.NumToChn( accountBook.InvoiceItemSumTotal.ToString( ) );
                reportPrinter.PrintPreview(false);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }