/// <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); } oleDb.BeginTransaction( ); try { HIS.Model.MZ_Account new_mz_account = new HIS.Model.MZ_Account( ); new_mz_account.AccountCode = userId.ToString( ); new_mz_account.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime; new_mz_account.Total_Fee = accountBook.InvoiceItemSumTotal; new_mz_account.Cash_Fee = 0; new_mz_account.POS_Fee = 0; new_mz_account.BlankOut = strblankoutInvoices; //新增账单 HIS.SYSTEM.Core.BindEntity <HIS.Model.MZ_Account> .CreateInstanceDAL(oleDb).Add(new_mz_account); //当前对象ID赋值 int accountBookId = new_mz_account.AccountID; //更新结算表,置账单号 List <HIS.Model.MZ_CostMaster> list_costmaster = HIS.SYSTEM.Core.BindEntity <HIS.Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).GetListArray(" RECORD_FLAG<>9 and ACCOUNTID=0 and CHARGECODE='" + userId + "'"); if (list_costmaster.Count == 0) { throw new OperatorException("没有科目可以交账!"); } for (int i = 0; i < list_costmaster.Count; i++) { list_costmaster[i].AccountID = accountBookId; HIS.SYSTEM.Core.BindEntity <HIS.Model.MZ_CostMaster> .CreateInstanceDAL(oleDb).Update(list_costmaster[i]); } oleDb.CommitTransaction( ); return(true); } catch (OperatorException operr) { oleDb.RollbackTransaction( ); throw operr; } catch (Exception err) { oleDb.RollbackTransaction( ); ErrorWriter.WriteLog(err.Message); throw new Exception("交款处理发生错误!"); } }
/// <summary> /// 获取指定时间段指定的收费员的交账单 /// </summary> /// <param name="TollCollectorId">收费员ID</param> /// <param name="BeginDate">开始时间</param> /// <param name="EndDate">结束时间</param> /// <returns></returns> public static List <PrivyAccountBook> GetPrivyAccountBooks(int TollCollectorId, DateTime BeginDate, DateTime EndDate) { DataTable tbAccountList = GetAccountList(BeginDate, EndDate); DataRow[] drsAccountList = tbAccountList.Select(Tables.mz_account.ACCOUNTID + "='" + TollCollectorId.ToString() + "'"); int[] accountBookid = new int[drsAccountList.Length]; for (int i = 0; i < drsAccountList.Length; i++) { accountBookid[i] = Convert.ToInt32(drsAccountList[i][Tables.mz_account.ACCOUNTID]); } DataTable tbInvoiceList; DataTable tbInvoiceDetailList; GetAccountData(TollCollectorId, accountBookid, out tbInvoiceList, out tbInvoiceDetailList); List <PrivyAccountBook> lstBooks = new List <PrivyAccountBook>(); for (int i = 0; i < accountBookid.Length; i++) { PrivyAccountBook book = GetPrivyAccountBook(TollCollectorId, accountBookid[i], tbInvoiceList, tbInvoiceDetailList, tbAccountList); lstBooks.Add(book); } return(lstBooks); }
/// <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 = PublicDataReader.GetEmployeeNameById( TollCollectorId ); accountBook.TollCollectorName = BaseDataController.GetName(BaseDataCatalog.人员列表, 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 = PublicDataReader.GetEmployeeNameById( TollCollectorId ); chargeBillInfo.ChargeName = BaseDataController.GetName(BaseDataCatalog.人员列表, 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( ); //退票 List <Invoice> lstChargeRefundInvoice = new List <Invoice>( ); if (chargeBillinfo.RefundInvoice != null) { lstChargeRefundInvoice = chargeBillinfo.RefundInvoice.ToList( ); } if (book.ChargeInvoiceInfo.RefundInvoice != null) { for (int i = 0; i < book.ChargeInvoiceInfo.RefundInvoice.Length; i++) { lstChargeRefundInvoice.Add(book.ChargeInvoiceInfo.RefundInvoice[i]); } } chargeBillinfo.RefundInvoice = lstChargeRefundInvoice.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( ); List <Invoice> lstRegRefundInvoice = new List <Invoice>( ); if (registerBillinfo.RefundInvoice != null) { lstRegRefundInvoice = registerBillinfo.RefundInvoice.ToList( ); } if (book.RegisterInvoiceInfo.RefundInvoice != null) { for (int i = 0; i < book.RegisterInvoiceInfo.RefundInvoice.Length; i++) { lstRegRefundInvoice.Add(book.RegisterInvoiceInfo.RefundInvoice[i]); } } registerBillinfo.RefundInvoice = lstRegRefundInvoice.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); }