/// <summary> /// 药品平账 /// </summary> /// <param name="deptId">药剂科室ID</param> public override void BalanceAccount(int deptId) { try { //获取对账错误的药品信息 //触发事件 _monthEvent.CurrentState = MonthAccountState.SystemChecking; AccountHandler(_monthEvent); DataTable wrongAccountDt = SystemCheckAccount(deptId); AccountQuery query = AccountFactory.GetQuery(ConfigManager.YK_SYSTEM); IBaseDAL <YP_Account> accountDao = BindEntity <YP_Account> .CreateInstanceDAL(oleDb, BLL.Tables.YK_ACCOUNT); if (wrongAccountDt.Rows.Count > 0) { //触发事件 _monthEvent.CurrentState = MonthAccountState.WriteAdjAccount; AccountHandler(_monthEvent); AdjAccount(deptId, wrongAccountDt, query, accountDao); } //触发事件 _monthEvent.CurrentState = MonthAccountState.Over; AccountHandler(_monthEvent); } catch (Exception error) { if (oleDb.IsInTransaction) { oleDb.RollbackTransaction(); } throw error; } }
/// <summary> /// 账目调整算法 /// </summary> /// <param name="deptId">药剂科室ID</param> /// <param name="wrongAccountDt">错误账目信息表</param> /// <param name="query">账务查询器</param> /// <param name="accountDao">台帐表操作对象</param> protected static void AdjAccount(int deptId, DataTable wrongAccountDt, AccountQuery query, IBaseDAL <YP_Account> accountDao) { DateTime currentTime = XcDate.ServerDateTime; //获取当前会计年月 int currentActYear = 0, currentActMonth = 0; query.GetAccountTime(currentTime, ref currentActYear, ref currentActMonth, deptId); string opType = ""; if (query.GetType().ToString() == "HIS.YP_BLL.YK_AccountQuery") { opType = ConfigManager.OP_YK_MONTHACCOUNT; } else if (query.GetType().ToString() == "HIS.YP_BLL.YF_AccountQuery") { opType = ConfigManager.OP_YF_MONTHACCOUNT; } else { throw new Exception("账目调节系统类型错误"); } oleDb.BeginTransaction(); //按错误药品信息依次写入调整台帐,把账目调平 for (int index = 0; index < wrongAccountDt.Rows.Count; index++) { DataRow currentRow = wrongAccountDt.Rows[index]; YP_Account adjAccount = new YP_Account(); adjAccount.AccountMonth = currentActMonth; adjAccount.AccountType = 3; adjAccount.AccountYear = currentActYear; adjAccount.MakerDicID = Convert.ToInt32(currentRow["MAKERDICID"]); adjAccount.LeastUnit = Convert.ToInt32(currentRow["UNIT"]); adjAccount.UnitNum = Convert.ToInt32(currentRow["UNITNUM"]); if (currentRow["WRONGFEE"] != DBNull.Value) { adjAccount.LenderFee = Convert.ToDecimal(currentRow["WRONGFEE"]) + Convert.ToDecimal(currentRow["STOREWRONGFEE"]); } if (currentRow["WRONGNUM"] != DBNull.Value) { adjAccount.LenderNum = Convert.ToDecimal(currentRow["WRONGNUM"]); } if (currentRow["BALANCEFEE"] != DBNull.Value) { adjAccount.BalanceFee = Convert.ToDecimal(currentRow["BALANCEFEE"]) + Convert.ToDecimal(currentRow["STOREWRONGFEE"]); } if (currentRow["BALANCENUM"] != DBNull.Value) { adjAccount.OverNum = Convert.ToDecimal(currentRow["BALANCENUM"]) + adjAccount.LenderNum; } adjAccount.DeptID = deptId; adjAccount.OpType = opType; adjAccount.RegTime = currentTime; accountDao.Add(adjAccount); } oleDb.CommitTransaction(); }
/// <summary> /// 构造账务查询器 /// </summary> /// <param name="belongSystem">所属系统(药房,药库系统)</param> /// <returns>账务查询器</returns> public static AccountQuery GetQuery(string belongSystem) { switch (belongSystem) { case ConfigManager.YF_SYSTEM: accountQuery = new YF_AccountQuery(); break; case ConfigManager.YK_SYSTEM: accountQuery = new YK_AccountQuery(); break; default: return(null); } return(accountQuery); }