Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="billMaster"></param>
        public override void DelBill(BillMaster billMaster)
        {
            try
            {
                YP_OutMaster outStore = (YP_OutMaster)billMaster;
                oleDb.BeginTransaction();
                IBaseDAL <YP_OutMaster> masterDao = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_OUTMASTER);

                //删除表头信息
                masterDao.Update(BLL.Tables.yf_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + outStore.MasterOutStorageID,
                                 BLL.Tables.yf_outmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                //如果是药品平级调拨
//add  平级药房调拨 张运辉 [20100531]
                object obj = HIS.SYSTEM.Core.BindEntity <HIS.BLL.Tables.yp_deptdic> .CreateInstanceDAL(oleDb).GetFieldValue("DEPTTYPE1", "DEPTID=" + outStore.OutDeptId);

                if (obj != null && obj.ToString() == "药房")
                {
                    IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                    yfInMaster.Update("BillNum=" + outStore.RelationNum.ToString()
                                      + " AND OpType='" + ConfigManager.OP_YF_APPLYIN + "'"
                                      + " AND Audit_Flag=0" + " AND DeptID=" + outStore.OutDeptId.ToString(), "DEL_FLAG=1");
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Example #2
0
 /// <summary>
 /// 构造DAL对象
 /// </summary>
 /// <param name="userInfo">用户信息</param>
 /// <param name="dbType">数据库类型</param>
 private void BuildDal(UserInfo userInfo, DatabaseType?dbType)
 {
     //先判断有没有自定义重写数据层
     try
     {
         Type customerDalType = Bridge.BridgeObject.GetDALType(typeof(T));
         if (customerDalType != null) //有自定义重写类,取自定义数据层对象
         {
             object obj = Activator.CreateInstance(customerDalType, new object[] { userInfo });
             if (obj != null)
             {
                 _dal = obj as BaseDAL <T>;
             }
             else
             {
                 _dal = new BaseDAL <T>(userInfo, dbType);
             }
         }
         else
         {
             _dal = new BaseDAL <T>(userInfo, dbType);
         }
     }
     catch
     {
         _dal = new BaseDAL <T>(userInfo, dbType);
     }
 }
Example #3
0
 /// <summary>
 /// 写药库期初台帐
 /// </summary>
 /// <param name="accountList">所有药品月结前最后一笔台帐记录</param>
 /// <param name="accountDao">台帐表操作对象</param>
 protected override void WriteBeginDateAccount(List <YP_Account> accountList, IBaseDAL <YP_Account> accountDao)
 {
     try
     {
         foreach (YP_Account account in accountList)
         {
             if (account.AccountMonth == 12)
             {
                 account.AccountYear++;
                 account.AccountMonth = 1;
             }
             else
             {
                 account.AccountMonth++;
             }
             account.Balance_Flag = 0;
             account.AccountType  = 0;
             account.OpType       = ConfigManager.OP_YK_MONTHACCOUNT;
             accountDao.Add(account);
         }
     }
     catch (Exception error)
     {
         throw error;
     }
 }
Example #4
0
        /// <summary>
        /// 写入台帐
        /// </summary>
        /// <param name="billMaster">单据头表信息</param>
        /// <param name="orderList">单据明细信息</param>
        /// <param name="storeTable">库存处理后的最新药品库存信息</param>
        public override void WriteAccount(BillMaster billMaster, List <BillOrder> orderList, Hashtable storeTable)
        {
            try
            {
                int                   actYear = 0, actMonth = 0;
                decimal               storeNum;
                int                   smallUnit;
                YP_CheckMaster        master     = (YP_CheckMaster)billMaster;
                IBaseDAL <YP_Account> accountDao = BindEntity <YP_Account> .CreateInstanceDAL(oleDb, HIS.BLL.Tables.YF_ACCOUNT);

                AccountFactory.GetQuery(ConfigManager.YF_SYSTEM).GetAccountTime(master.AuditTime, ref actYear,
                                                                                ref actMonth, master.DeptID);
                foreach (YP_CheckOrder order in orderList)
                {
                    if (order.CheckNum != order.FactNum)
                    {
                        storeNum  = ((YP_StoreNum)(storeTable[order.MakerDicID])).storeNum;
                        smallUnit = ((YP_StoreNum)(storeTable[order.MakerDicID])).smallUnit;
                        YP_Account account = BuildAccount(billMaster, order, storeNum, actYear, actMonth, smallUnit);
                        ComputeFee(account);
                        accountDao.Add(account);
                    }
                }
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Example #5
0
        /// <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;
            }
        }
Example #6
0
        /// <summary>
        /// 删除药房期初入库单
        /// </summary>
        /// <param name="billMaster">药房期初入库单表头</param>
        public override void DelBill(BillMaster billMaster)
        {
            try
            {
                YP_InMaster inStore = (YP_InMaster)billMaster;
                oleDb.BeginTransaction();
                IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                yfInMaster.Update(BLL.Tables.yf_inmaster.MASTERINSTORAGEID + oleDb.EuqalTo() + inStore.MasterInStorageID,
                                  BLL.Tables.yf_inmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                int deleteID = ypDal.YK_Outmaster_GetIDByBillNum(inStore.BillNum, inStore.DeptID);
                //做关联删除
                if (deleteID != -1)
                {
                    IBaseDAL <YP_OutMaster> ykOutMaster = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTMASTER);

                    ykOutMaster.Update(BLL.Tables.yk_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + deleteID,
                                       BLL.Tables.yk_outmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
        /// <summary>
        /// 设置月结日
        /// </summary>
        /// <param name="accountDay">新设置的月结日</param>
        /// <param name="deptId">部门ID</param>
        public static void SetAccountDay(int accountDay, int deptId)
        {
            try
            {
                YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                oleDb.BeginTransaction();
                //获取月结类型的全局参数
                IBaseDAL <YP_CONFIG> appDal = BindEntity <YP_CONFIG> .CreateInstanceDAL(oleDb);

                YP_CONFIG accDay = appDal.GetModel("CODE='008' AND DeptID=" + deptId);
                if (accDay != null)
                {
                    accDay.VALUE = accountDay.ToString();
                    appDal.Update(accDay);
                }
                else
                {
                    throw new Exception("药品系统参数表未进行初始化设置");
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("===Start Project===");

                //IBaseDAL baseDAL = new BaseDAL();
                IBaseDAL baseDAL = DALFactory.CreateInstance();
                Company  company = baseDAL.Find <Company>(1);
                //Company company1 = baseDAL.Find<Company>(1);
                //Company company2 = baseDAL.Find<Company>(1);
                //List<Company> listCompanies = baseDAL.FindAll<Company>();

                //User user = baseDAL.Find<User>(1);
                //List<User> list = baseDAL.FindAll<User>();

                company.Name = "Vodafone1";
                baseDAL.Update <Company>(company);
                //bool isRightName=company.Validate();


                Console.Read();
            }
            catch (Exception ex)
            {
                Console.WriteLine("=======Error Message=============");
                Console.WriteLine(ex);
                Console.WriteLine("=======End of Error Message=============");
            }

            Console.Read();
        }
Example #9
0
        /// <summary>
        /// 参数赋值后,初始化相关对象
        /// </summary>
        /// <param name="bllFullName">BLL业务类的全名(子类必须实现),子类构造函数传入this.GetType().FullName</param>
        /// <param name="dalAssemblyName">数据访问层程序集的清单文件的文件名,不包括其扩展名。设置为NULL或默认为Assembly.GetExecutingAssembly().GetName().Name</param>
        /// <param name="bllPrefix">BLL命名空间的前缀(BLL.)</param>
        /// <param name="dbConfigName">数据库配置项名称</param>
        protected void Init(string bllFullName, string dalAssemblyName = null, string dbConfigName = null, string bllPrefix = "BLL.")
        {
            if (string.IsNullOrEmpty(bllFullName))
            {
                throw new ArgumentNullException("子类未设置bllFullName业务类全名!");
            }

            if (string.IsNullOrEmpty(dalAssemblyName))
            {
                dalAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            }

            //赋值,准备构建对象
            this.bllFullName     = bllFullName;
            this.dalAssemblyName = dalAssemblyName;
            this.bllPrefix       = bllPrefix;

            //根据不同的数据库类型,构造相应的DAL层
            AppConfig config    = new AppConfig();
            string    dbType    = config.AppConfigGet("ComponentDbType");
            string    DALPrefix = GetDALPrefix(dbType);

            this.dalName = bllFullName.Replace(bllPrefix, DALPrefix);                      //替换中级的BLL.为DAL.,就是DAL类的全名
            baseDal      = Reflect <IBaseDAL <T> > .Create(this.dalName, dalAssemblyName); //构造对应的DAL数据访问层的对象类

            if (!string.IsNullOrEmpty(dbConfigName))
            {
                baseDal.SetDbConfigName(dbConfigName); //设置数据库配置项名称
            }
        }
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="billMaster">单据头表</param>
        public override void DelBill(BillMaster billMaster)
        {
            try
            {
                YP_OutMaster outStore = (YP_OutMaster)billMaster;
                oleDb.BeginTransaction();
                YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                IBaseDAL <YP_OutMaster> ykmasterDao = BindEntity <YP_OutMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_OUTMASTER);

                //删除表头信息
                ykmasterDao.Update(BLL.Tables.yk_outmaster.MASTEROUTSTORAGEID + oleDb.EuqalTo() + outStore.MasterOutStorageID,
                                   BLL.Tables.yf_outmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                if (outStore.OpType == ConfigManager.OP_YK_OUTTOYF)
                {
                    IBaseDAL <YP_InMaster> yfmasterDao = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                    //删除表头信息
                    YP_InMaster deleteMaster = yfmasterDao.GetModel("BillNum=" + outStore.RelationNum.ToString()
                                                                    + " AND OpType='" + ConfigManager.OP_YF_APPLYIN + "'"
                                                                    + " AND DeptID=" + outStore.OutDeptId.ToString());
                    if (deleteMaster != null)
                    {
                        deleteMaster.Del_Flag = 1;
                        yfmasterDao.Update(deleteMaster);
                    }
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Example #11
0
        /// <summary>
        /// 修改采购计划单
        /// </summary>
        /// <param name="billMaster">采购计划表头</param>
        /// <param name="listOrder">采购计划明细列表</param>
        /// <param name="deptId">药剂科室ID</param>
        public override void UpdateBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId)
        {
            try
            {
                YP_PlanMaster planMaster = (YP_PlanMaster)billMaster;
                oleDb.BeginTransaction();
                //声明操作对象
                IBaseDAL <YP_PlanMaster> masterDao = BindEntity <YP_PlanMaster> .CreateInstanceDAL(oleDb, Tables.YK_PLANMASTER);

                IBaseDAL <YP_PlanOrder> orderDao = BindEntity <YP_PlanOrder> .CreateInstanceDAL(oleDb, Tables.YK_PLANORDER);

                planMaster.RetailFee = 0;
                planMaster.TradeFee  = 0;
                orderDao.Delete(Tables.yk_planorder.PLANMASTERID + oleDb.EuqalTo() + planMaster.PlanMasterId);
                foreach (YP_PlanOrder planOrder in listOrder)
                {
                    //计算入库金额
                    planMaster.RetailFee  += planOrder.RetailFee;
                    planMaster.TradeFee   += planOrder.TradeFee;
                    planOrder.PlanMasterId = planMaster.PlanMasterId;
                    //依次添加明细记录
                    orderDao.Add(planOrder);
                }
                masterDao.Update(planMaster);
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Example #12
0
        /// <summary>
        /// 保存采购计划单
        /// </summary>
        /// <param name="billMaster">采购计划表头</param>
        /// <param name="listOrder">采购计划明细列表</param>
        /// <param name="deptId">药剂科室ID</param>
        public override void SaveBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId)
        {
            try
            {
                YP_PlanMaster            planMaster = (YP_PlanMaster)billMaster;
                IBaseDAL <YP_PlanMaster> masterDao  = BindEntity <YP_PlanMaster> .CreateInstanceDAL(oleDb, Tables.YK_PLANMASTER);

                IBaseDAL <YP_PlanOrder> orderDao = BindEntity <YP_PlanOrder> .CreateInstanceDAL(oleDb, Tables.YK_PLANORDER);

                planMaster.RegTime       = XcDate.ServerDateTime;
                planMaster.LASTCHANGTIME = XcDate.ServerDateTime;
                planMaster.TradeFee      = 0;
                planMaster.RetailFee     = 0;
                oleDb.BeginTransaction();
                //写头表信息获取ID号
                masterDao.Add(planMaster);
                foreach (YP_PlanOrder planOrder in listOrder)
                {
                    //计算头表合计金额
                    planMaster.RetailFee  += planOrder.RetailFee;
                    planMaster.TradeFee   += planOrder.TradeFee;
                    planOrder.PlanMasterId = planMaster.PlanMasterId;
                    //依次添加明细记录
                    orderDao.Add(planOrder);
                }
                masterDao.Update(planMaster);
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Example #13
0
        /// <summary>
        /// 根据入库表头生成出库表头并添加到数据库中
        /// </summary>
        /// <param name="masterDao">出库表头数据访问对象</param>
        /// <param name="inMaster">入库表头</param>
        /// <param name="ypDal">数据访问层对象</param>
        /// <param name="storedeptId">入库部门ID</param>
        private YP_OutMaster AddYKOutMaster(IBaseDAL <YP_OutMaster> masterDao, YP_InMaster inMaster, YP_Dal ypDal, int storedeptId)
        {
            YP_OutMaster outMaster = new YP_OutMaster();

            if (HIS.SYSTEM.Core.BindEntity <object> .CreateInstanceDAL(oleDb, "YP_DEPTDIC").GetFieldValue("DEPTTYPE1", "DEPTID=" + storedeptId).ToString() == "药房")
            {
                boPjdb = true;
            }
            else
            {
                boPjdb = false;
            }
            if (boPjdb == true)
            {
                ChangeInmasterToOutmaster1(inMaster, storedeptId, outMaster);
                //update 20100624
                outMaster.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YF_DEPTDRAW, storedeptId).BillNum;
            }
            else
            {
                ChangeInmasterToOutmaster(inMaster, storedeptId, outMaster);
                //update 20100624
                outMaster.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_OUTTOYF, storedeptId).BillNum;
            }
            masterDao.Add(outMaster);
            return(outMaster);
        }
Example #14
0
        /// <summary>
        /// 参数赋值后,初始化相关对象
        /// </summary>
        /// <param name="bllFullName">BLL业务类的全名(子类必须实现),子类构造函数传入this.GetType().FullName</param>
        /// <param name="dalAssemblyName">数据访问层程序集的清单文件的文件名,不包括其扩展名。设置为NULL或默认为Assembly.GetExecutingAssembly().GetName().Name</param>
        /// <param name="bllPrefix">BLL命名空间的前缀(BLL.)</param>
        /// <param name="dbConfigName">数据库配置项名称</param>
        protected void Init(string bllFullName, string dalAssemblyName = null, string dbConfigName = null, string bllPrefix = "BLL.")
        {
            if (string.IsNullOrEmpty(bllFullName))
            {
                throw new ArgumentNullException("子类未设置bllFullName业务类全名!");
            }

            if (string.IsNullOrEmpty(dalAssemblyName))
            {
                dalAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            }

            //赋值,准备构建对象
            this.bllFullName = bllFullName;
            //this.dalAssemblyName = dalAssemblyName;
            this.bllPrefix = bllPrefix;

            #region 根据不同的数据库类型,构造相应的DAL层

            string dbType = config.AppConfigGet("ComponentDbType");
            if (string.IsNullOrEmpty(dbType))
            {
                dbType = "sqlserver";
            }
            dbType = dbType.ToLower();

            string DALPrefix = "";
            if (dbType == "sqlserver")
            {
                DALPrefix = "SQLServerDAL.";
            }
            else if (dbType == "access")
            {
                DALPrefix = "AccessDAL.";
            }
            else if (dbType == "oracle")
            {
                DALPrefix = "OracleDAL.";
            }
            else if (dbType == "sqlite")
            {
                DALPrefix = "SQLiteDAL.";
            }
            else if (dbType == "mysql")
            {
                DALPrefix = "MySqlDAL.";
            }
            #endregion

            this.dalName         = bllFullName.Replace(bllPrefix, DALPrefix);//替换中级的BLL.为DAL.,就是DAL类的全名
            this.dalAssemblyName = dalAssemblyName.Replace(bllPrefix.Replace(".", ""), DALPrefix.Replace(".", ""));
            //baseDal = Reflect<IBaseDAL<T>>.Create(this.dalName, dalAssemblyName);//构造对应的DAL数据访问层的对象类
            // CREATE 命名空间, 程序集名(JCodes.Framework.SQLServerDAL.DictType, JCodes.Framework.SQLServerDAL)
            baseDal = Reflect <IBaseDAL <T> > .Create(this.dalName, this.dalAssemblyName);//构造对应的DAL数据访问层的对象类

            if (!string.IsNullOrEmpty(dbConfigName))
            {
                baseDal.SetDbConfigName(dbConfigName); //设置数据库配置项名称
            }
        }
Example #15
0
        /// <summary>
        /// 写入台帐
        /// </summary>
        /// <param name="billMaster">单据头表信息</param>
        /// <param name="orderList">单据明细信息</param>
        /// <param name="storeTable">库存处理后的最新药品库存信息</param>
        public override void WriteAccount(BillMaster billMaster, List <BillOrder> orderList, System.Collections.Hashtable storeTable)
        {
            try
            {
                int                   actYear = 0, actMonth = 0;
                YP_InMaster           master     = (YP_InMaster)billMaster;
                IBaseDAL <YP_Account> accountDao = BindEntity <YP_Account> .CreateInstanceDAL(oleDb, HIS.BLL.Tables.YK_ACCOUNT);

                AccountFactory.GetQuery(ConfigManager.YK_SYSTEM).GetAccountTime(master.AuditTime, ref actYear,
                                                                                ref actMonth, master.DeptID);
                foreach (YP_InOrder order in orderList)
                {
                    string     queryKey  = order.MakerDicID.ToString() + order.BatchNum.ToString();
                    decimal    storeNum  = ((YP_StoreNum)(storeTable[queryKey])).storeNum;
                    int        smallUnit = ((YP_StoreNum)(storeTable[queryKey])).smallUnit;
                    YP_Account account   = BuildAccount(billMaster, order, storeNum, actYear, actMonth, smallUnit);
                    ComputeFee(account);
                    accountDao.Add(account);
                }
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Example #16
0
        /// <summary>
        /// 参数赋值后,初始化相关对象
        /// </summary>
        /// <param name="bllFullName">BLL业务类的全名(子类必须实现),子类构造函数传入this.GetType().FullName</param>
        /// <param name="dalAssemblyName">数据访问层程序集的清单文件的文件名,不包括其扩展名。设置为NULL或默认为Assembly.GetExecutingAssembly().GetName().Name</param>
        /// <param name="bllPrefix">BLL命名空间的前缀(BLL.)</param>
        /// <param name="dbConfigName">数据库配置项名称</param>
        protected void Init(string bllFullName, string dalAssemblyName = null, string dbConfigName = null, string bllPrefix = "BLL.")
        {
            if (string.IsNullOrEmpty(bllFullName))
            {
                throw new ArgumentNullException("子类未设置bllFullName业务类全名!");
            }

            if (string.IsNullOrEmpty(dalAssemblyName))
            {
                dalAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            }

            //赋值,准备构建对象
            this.bllFullName     = bllFullName;
            this.dalAssemblyName = dalAssemblyName;
            this.bllPrefix       = bllPrefix;

            #region 根据不同的数据库类型,构造相应的DAL层
            AppConfig config = new AppConfig();
            string    dbType = config.AppConfigGet("ComponentDbType");
            if (string.IsNullOrEmpty(dbType))
            {
                dbType = "sqlserver";
            }
            dbType = dbType.ToLower();

            string DALPrefix = "";
            if (dbType == "sqlserver")
            {
                DALPrefix = "DALSQL.";
            }
            else if (dbType == "access")
            {
                DALPrefix = "DALAccess.";
            }
            else if (dbType == "oracle")
            {
                DALPrefix = "DALOracle.";
            }
            else if (dbType == "sqlite")
            {
                DALPrefix = "DALSQLite.";
            }
            else if (dbType == "mysql")
            {
                DALPrefix = "DALMySql.";
            }
            #endregion

            this.dalName = bllFullName.Replace(bllPrefix, DALPrefix);                      //替换中级的BLL.为DAL.,就是DAL类的全名
            baseDal      = Reflect <IBaseDAL <T> > .Create(this.dalName, dalAssemblyName); //构造对应的DAL数据访问层的对象类

            if (!string.IsNullOrEmpty(dbConfigName))
            {
                baseDal.SetDbConfigName(dbConfigName); //设置数据库配置项名称
            }
        }
Example #17
0
        static void Main(string[] args)
        {
            IBaseDAL dAL = SimpleFactory.CreateInstance();

            dAL.GetT <Company>(1).Show();

            dAL.GetT <User>(1).Show();
            Console.Read();
        }
Example #18
0
        /// <summary>
        /// 审核药房申请入库单
        /// </summary>
        /// <param name="billMaster">药房申请入库单表头</param>
        /// <param name="auditerID">审核人员ID</param>
        /// <param name="auditDeptID">审核科室ID</param>
        public override void AuditBill(BillMaster billMaster, long auditerID, long auditDeptID)
        {
            YP_InMaster inStore = (YP_InMaster)billMaster;

            try
            {
                ////update 20100624
                if (HIS.SYSTEM.Core.BindEntity <object> .CreateInstanceDAL(oleDb, "YP_DEPTDIC").GetFieldValue("DEPTTYPE1", "DEPTID=" + inStore.DeptID).ToString() == "药房")
                {
                    boPjdb = true;
                }
                else
                {
                    boPjdb = false;
                }
                if (billMaster == null)
                {
                    throw new Exception("对应领药单丢失");
                }
                IBaseDAL <YP_InMaster> yfInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INMASTER);

                IBaseDAL <YP_InOrder> yfInOrder = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YF_INORDER);

                List <YP_InOrder> listOrder     = yfInOrder.GetListArray("MasterInStorageID=" + inStore.MasterInStorageID + "");
                List <BillOrder>  billListOrder = new List <BillOrder>();
                base.AuditPrice(inStore, listOrder, ConfigManager.YF_SYSTEM);
                inStore.AuditTime     = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                inStore.Audit_Flag    = 1;
                inStore.AuditPeopleID = Convert.ToInt32(auditerID);
                yfInMaster.Update(inStore);
                foreach (YP_InOrder orderInstore in listOrder)
                {
                    orderInstore.Audit_Flag = 1;
                    yfInOrder.Update(orderInstore);
                    billListOrder.Add(orderInstore);
                }


                Hashtable storeTable;
                if (((YP_InMaster)billMaster).OpType == ConfigManager.OP_YF_PJDB)
                {
                    ((YP_InMaster)billMaster).OpType = ConfigManager.OP_YF_APPLYIN;
                    storeTable = StoreFactory.GetProcessor(ConfigManager.OP_YF_APPLYIN).ChangeStoreNum(billMaster, billListOrder);
                }
                else
                {
                    storeTable = StoreFactory.GetProcessor(inStore.OpType).ChangeStoreNum(billMaster, billListOrder);
                }
                AccountFactory.GetWriter(inStore.OpType).WriteAccount(billMaster, billListOrder, storeTable);
            }
            catch (Exception error)
            {
                inStore.Audit_Flag = 0;
                throw error;
            }
        }
Example #19
0
 public ComponentBLL()
 {
     try
     {
         dal = DALLocator.GetComponentDAL();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #20
0
 public ProductBLL()
 {
     try
     {
         dal = DALLocator.GetProductDAL();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #21
0
        /// <summary>
        /// 保存采购入库单
        /// </summary>
        /// <param name="billMaster">采购入库单表头</param>
        /// <param name="listOrder">采购入库单明细</param>
        /// <param name="deptId">药剂科室ID</param>
        public override void SaveBill(BillMaster billMaster, List <BillOrder> listOrder, long deptId)
        {
            try
            {
                YP_InMaster masterInstore = (YP_InMaster)billMaster;
                YP_InOrder  inStore       = new YP_InOrder();
                oleDb.BeginTransaction();
                //声明操作对象
                IBaseDAL <YP_InMaster> inMasterDao = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER);

                IBaseDAL <YP_InOrder> inOrderDao = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INORDER);

                IBaseDAL <YP_Storage> storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YK_STORAGE);

                YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                //获取入库单据号
                if (masterInstore.OpType == ConfigManager.OP_YK_INOPTYPE)
                {
                    masterInstore.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_INOPTYPE, deptId).BillNum;
                }
                else if (masterInstore.OpType == ConfigManager.OP_YK_BACKSTORE)
                {
                    masterInstore.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_BACKSTORE, deptId).BillNum;
                }
                else
                {
                    masterInstore.BillNum = ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_FIRSTIN, deptId).BillNum;
                }
                inMasterDao.Add(masterInstore);
                foreach (BillOrder order in listOrder)
                {
                    //遍历DataTable取出明细记录并设置记录的值
                    inStore = (YP_InOrder)order;
                    //计算入库金额
                    masterInstore.RetailFee  += inStore.RetailFee;
                    masterInstore.StockFee   += inStore.StockFee;
                    masterInstore.TradeFee   += inStore.TradeFee;
                    inStore.MasterInStorageID = masterInstore.MasterInStorageID;
                    inStore.BillNum           = masterInstore.BillNum;
                    //依次添加明细记录
                    inOrderDao.Add(inStore);
                }
                inMasterDao.Update(masterInstore);
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Example #22
0
        /// <summary>
        /// 写药房期末台帐
        /// </summary>
        /// <param name="accountHis"></param>
        /// <param name="billNum"></param>
        /// <param name="accountDao"></param>
        /// <param name="deptId"></param>
        protected override void WriteBeginDateAccount(YP_AccountHis accountHis, int billNum,
                                                      IBaseDAL <YP_Account> accountDao, int deptId)
        {
            YP_Dal ypDal = new YP_Dal();

            ypDal._oleDb = oleDb;
            YP_Account account     = new YP_Account();
            DataTable  beginDataDt = ypDal.YF_Storage_GetListForAccount(deptId);

            for (int index = 0; index < beginDataDt.Rows.Count; index++)
            {
                DataRow dRow = beginDataDt.Rows[index];
                if (accountHis.RegTime.Month != 12)
                {
                    account.AccountMonth = accountHis.RegTime.Month + 1;
                    account.AccountYear  = accountHis.RegTime.Year;
                }
                else
                {
                    account.AccountMonth = 1;
                    account.AccountYear++;
                }
                account.Balance_Flag     = 0;
                account.BillNum          = billNum;
                account.DeptID           = deptId;
                account.AccountHistoryID = accountHis.AccountHistoryID;
                account.LeastUnit        = Convert.ToInt32(dRow["UNIT"]);
                account.MakerDicID       = Convert.ToInt32(dRow["MAKERDICID"]);
                account.OpType           = ConfigManager.OP_YF_MONTHACCOUNT;
                account.OrderID          = 0;
                account.RegTime          = accountHis.RegTime;
                account.RetailPrice      = Convert.ToDecimal(dRow["RETAILPRICE"]);
                account.StockPrice       = Convert.ToDecimal(dRow["TRADEPRICE"]);
                account.UnitNum          = Convert.ToInt32(dRow["PUNITNUM"]);
                account.OverNum          = Convert.ToInt32(dRow["CURRENTNUM"]);
                account.BalanceFee       = 0;
                int modNum = (Convert.ToInt32(account.OverNum) % Convert.ToInt32(account.UnitNum));
                if (modNum == 0)
                {
                    account.BalanceFee += (account.OverNum / account.UnitNum) * account.RetailPrice;
                }
                else
                {
                    account.BalanceFee += ((account.OverNum - modNum) / account.UnitNum) * account.RetailPrice;
                    account.BalanceFee += (Convert.ToDecimal(modNum) / Convert.ToDecimal(account.UnitNum)) * account.RetailPrice;
                }
                accountDao.Add(account);
            }
        }
Example #23
0
        public override YP_AccountHis GetLastAccountHis(int deptId)
        {
            try
            {
                IBaseDAL <YP_AccountHis> accountHisDao = BindEntity <YP_AccountHis> .CreateInstanceDAL(oleDb, BLL.Tables.YK_ACCOUNTHIS);

                int maxId = accountHisDao.GetMaxId(Tables.yk_accounthis.ACCOUNTHISTORYID,
                                                   Tables.yk_accounthis.DEPTID + oleDb.EuqalTo() + deptId);
                YP_AccountHis accountHistory = accountHisDao.GetModel(maxId);
                return(accountHistory);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Example #24
0
        public override decimal QueryNum(int makerDicId, int deptId)
        {
            IBaseDAL <YP_Storage> storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YK_STORAGE);

            YP_Storage currentStore = storeDao.GetModel("MakerDicID=" + makerDicId.ToString() +
                                                        " AND DeptId=" + deptId.ToString());

            if (currentStore != null)
            {
                return(currentStore.CurrentNum);
            }
            else
            {
                return(0);
            }
        }
Example #25
0
        public override Hashtable ChangeStoreNum(BillMaster billMaster, List <BillOrder> orderList)
        {
            try
            {
                Hashtable   storeNumHash = new Hashtable();
                YP_InMaster inStore      = (YP_InMaster)billMaster;
                foreach (BillOrder order in orderList)
                {
                    YP_StoreNum storeNum     = new YP_StoreNum();
                    YP_InOrder  orderInstore = (YP_InOrder)order;
                    storeNum.makerDicId = orderInstore.MakerDicID;
                    storeNum.smallUnit  = orderInstore.LeastUnit;
                    IBaseDAL <YP_Storage> storeDao = BindEntity <YP_Storage> .CreateInstanceDAL(oleDb, BLL.Tables.YK_STORAGE);

                    //增加库存
                    decimal rtn = base.AddStoreNum(orderInstore.MakerDicID, orderInstore.DeptID, orderInstore.InNum);
                    if (rtn == -1)
                    {
                        YP_Storage drugStore = new YP_Storage();
                        drugStore.CurrentNum  = orderInstore.InNum;
                        drugStore.Del_Flag    = 0;
                        drugStore.DeptID      = inStore.DeptID;
                        drugStore.LeastUnit   = storeNum.smallUnit;
                        drugStore.LowerLimit  = 0;
                        drugStore.LStockPrice = orderInstore.StockPrice;
                        drugStore.MakerDicID  = orderInstore.MakerDicID;
                        drugStore.RegTime     = inStore.RegTime;
                        drugStore.UnitNum     = orderInstore.UnitNum;
                        drugStore.UpperLimit  = 0;
                        storeDao.Add(drugStore);
                        storeNum.storeNum = orderInstore.InNum;
                    }
                    else
                    {
                        storeNum.storeNum = rtn;
                    }
                    storeNum.queryKey = orderInstore.MakerDicID.ToString() + orderInstore.BatchNum.ToString();
                    storeNumHash.Add(storeNum.queryKey, storeNum);
                }
                BatchProcessor.AddBatchNum(orderList, inStore.RegTime);
                return(storeNumHash);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Example #26
0
        public BaseBLL(string dalName)
        {
#if false //原来的代码如下
            #region 根据不同的数据库类型,构造相应的DAL层
            AppConfig config = new AppConfig();
            string    dbtype = config.AppConfigGet("ComponentDbType");
            if (string.IsNullOrEmpty(dbtype))
            {
                dbtype = "sqlserver";
            }
            dbtype = dbtype.ToLower();

            string DALPrefix = "";
            if (dbtype == "sqlserver")
            {
                DALPrefix = "DALSQL.";
            }
            else if (dbtype == "access")
            {
                DALPrefix = "DALAccess.";
            }
            else if (dbtype == "oracle")
            {
                DALPrefix = "DALOracle.";
            }

            #endregion
            if (string.IsNullOrEmpty(dalName))
            {
                this.dalName = GetType().FullName.Replace("BLL", DALPrefix);
            }
            else
            {
                this.dalName = dalName;
            }

            baseDal = Reflect <IBaseDAL <T> > .Create(this.dalName, "WHC.WareHouseMis");
#endif
            this.dalName = dalName;
            if (string.IsNullOrEmpty(dalName))
            {
                this.dalName = GetType().FullName.Replace("BLL", "DAL");
            }

            baseDal = Reflect <IBaseDAL <T> > .Create(this.dalName, "TMIS");
        }
Example #27
0
 /// <summary>
 /// 写药库期末台帐
 /// </summary>
 /// <param name="accountList">台帐信息明细</param>
 /// <param name="accountDao">台帐表操作对象</param>
 /// <param name="ypStore">药品库存表操作对象</param>
 protected override void WriteEndDateAccount(List <YP_Account> accountList, IBaseDAL <YP_Account> accountDao,
                                             IBaseDAL <YP_Storage> ypStore)
 {
     try
     {
         foreach (YP_Account account in accountList)
         {
             account.Balance_Flag = 1;
             account.AccountType  = 1;
             account.OpType       = ConfigManager.OP_YK_MONTHACCOUNT;
             accountDao.Add(account);
         }
     }
     catch (Exception error)
     {
         throw error;
     }
 }
Example #28
0
        /// <summary>
        /// 删除采购入库单
        /// </summary>
        /// <param name="billMaster">单据表头</param>
        public override void DelBill(BillMaster billMaster)
        {
            try
            {
                YP_InMaster inStore = (YP_InMaster)billMaster;
                oleDb.BeginTransaction();
                IBaseDAL <YP_InMaster> ykInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER);

                ykInMaster.Update(BLL.Tables.yk_inmaster.MASTERINSTORAGEID + oleDb.EuqalTo() + inStore.MasterInStorageID,
                                  BLL.Tables.yk_inmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Example #29
0
        /// <summary>
        /// 药库入库单审核
        /// </summary>
        /// <param name="billMaster">药库入库单头表</param>
        /// <param name="auditerID">审核人员ID</param>
        /// <param name="auditDeptID">审核部门ID</param>
        public override void AuditBill(BillMaster billMaster, long auditerID, long auditDeptID)
        {
            try
            {
                YP_InMaster inStore  = (YP_InMaster)billMaster;
                string      strWhere = BLL.Tables.yk_inmaster.MASTERINSTORAGEID + oleDb.EuqalTo() + inStore.MasterInStorageID
                                       + oleDb.And() + BLL.Tables.yk_inmaster.AUDIT_FLAG + oleDb.EuqalTo() + "1";
                if (BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER).Exists(strWhere))
                {
                    throw new Exception("该张单据已经审核过。。。");
                }
                oleDb.BeginTransaction();
                DateTime _currentTime = XcDate.ServerDateTime;
                inStore.AuditTime     = _currentTime;
                inStore.Audit_Flag    = 1;
                inStore.AuditPeopleID = Convert.ToInt32(auditerID);
                IBaseDAL <YP_InOrder> ykInOrder = BindEntity <YP_InOrder> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INORDER);

                IBaseDAL <YP_InMaster> ykInMaster = BindEntity <YP_InMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YK_INMASTER);

                List <YP_InOrder> listStore = ykInOrder.GetListArray("MasterInStorageID=" + inStore.MasterInStorageID + "");
                base.AuditPrice(inStore, listStore, ConfigManager.YK_SYSTEM);
                ykInMaster.Update(inStore);
                List <BillOrder> listOrder = new List <BillOrder>();
                AccountWriter    actWriter = AccountFactory.GetWriter(inStore.OpType);
                foreach (YP_InOrder orderInstore in listStore)
                {
                    orderInstore.Audit_Flag = 1;
                    ykInOrder.Update(orderInstore);
                    listOrder.Add(orderInstore);
                }
                Hashtable storeTable = StoreFactory.GetProcessor(inStore.OpType).ChangeStoreNum(billMaster, listOrder);
                AccountFactory.GetWriter(inStore.OpType).WriteAccount(billMaster, listOrder, storeTable);
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                if (oleDb.IsInTransaction)
                {
                    oleDb.RollbackTransaction();
                }
                throw error;
            }
        }
Example #30
0
        static void Main(string[] args)
        {
            try
            {
                IBaseDAL baseDal = DALFactory.CreateInstance();
                User     user    = baseDal.Query <User>(1);
                user.Name   = "12123";
                user.Mobile = "233421121";
                baseDal.Insert(user);
                Console.WriteLine("ok");
                Console.Read();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
Example #31
0
 public TestBLL(IBaseDAL ibBaseDal)
 {
     _iBaseDal = ibBaseDal;
 }