コード例 #1
0
        /// <summary>
        /// 将多张药库盘点单明细汇总到一张盘点明细表中
        /// </summary>
        /// <param name="totalListOrder">汇总明细表</param>
        /// <param name="listOrder">药库盘点单明细列表</param>
        private void AddOrderListByMakerId(List <BillOrder> totalListOrder, List <YP_CheckOrder> listOrder)
        {
            StoreQuery _storeQuery = StoreFactory.GetQuery(ConfigManager.YK_SYSTEM);

            foreach (YP_CheckOrder orderCheck in listOrder)
            {
                bool isFind = false;
                foreach (YP_CheckOrder totalOrder in totalListOrder)
                {
                    if (totalOrder.MakerDicID == orderCheck.MakerDicID)
                    {
                        totalOrder.CheckNum += orderCheck.CheckNum;
                        totalOrder.FactNum  += orderCheck.FactNum;
                        isFind = true;
                        break;
                    }
                }
                if (isFind == false)
                {
                    totalListOrder.Add((YP_CheckOrder)(orderCheck.Clone()));
                }
            }
            foreach (YP_CheckOrder totalOrder in totalListOrder)
            {
                decimal differentNum = totalOrder.CheckNum - totalOrder.FactNum;
                totalOrder.FactNum     = _storeQuery.QueryNum(totalOrder.MakerDicID, totalOrder.DeptID);
                totalOrder.CheckNum    = totalOrder.FactNum + differentNum;
                totalOrder.CKRetailFee = totalOrder.CheckNum * totalOrder.RetailPrice;
                totalOrder.CKTradeFee  = totalOrder.CheckNum * totalOrder.TradePrice;
                totalOrder.FTRetailFee = totalOrder.FactNum * totalOrder.RetailPrice;
                totalOrder.FTTradeFee  = totalOrder.FactNum * totalOrder.TradePrice;
            }
        }
コード例 #2
0
 /// <summary>
 /// 加载采购计划单据明细
 /// </summary>
 /// <param name="billMaster">单据头表</param>
 /// <returns></returns>
 public override DataTable LoadOrder(BillMaster billMaster)
 {
     if (billMaster != null)
     {
         YP_PlanMaster master = (YP_PlanMaster)billMaster;
         if (master.PlanMasterId != -1)
         {
             string strWhere = HIS.BLL.Tables.yk_planmaster.PLANMASTERID + oleDb.EuqalTo()
                               + master.PlanMasterId;
             YP_Dal dal = new YP_Dal();
             dal._oleDb = oleDb;
             return(dal.YK_PlanOrder_GetList(strWhere));
         }
         else
         {
             string strWhere = HIS.BLL.Tables.yk_planmaster.PLANMASTERID + oleDb.EuqalTo()
                               + master.PlanMasterId;
             YP_Dal dal = new YP_Dal();
             dal._oleDb = oleDb;
             DataTable  orderDt        = dal.YK_PlanOrder_GetList(strWhere);
             StoreQuery storeQuery     = StoreFactory.GetQuery(ConfigManager.YK_SYSTEM);
             DataTable  lowerStoreDrug = storeQuery.GetDrugForStoreLimit("", false,
                                                                         (int)master.DeptId, 0);
             for (int index = 0; index < lowerStoreDrug.Rows.Count; index++)
             {
                 DataRow limitRow = lowerStoreDrug.Rows[index];
                 decimal stockNum = Convert.ToDecimal(limitRow["UPPERLIMIT"]) -
                                    Convert.ToDecimal(limitRow["CURRENTNUM"]);
                 if (stockNum > 0)
                 {
                     DataRow newRow = orderDt.NewRow();
                     newRow["MAKERDICID"]   = limitRow["MAKERDICID"];
                     newRow["CHEMNAME"]     = limitRow["CHEMNAME"];
                     newRow["SPEC"]         = limitRow["SPEC"];
                     newRow["PRODUCTNAME"]  = limitRow["PRODUCTNAME"];
                     newRow["PLANMASTERID"] = 0;
                     newRow["PLANORDERID"]  = 0;
                     newRow["RETAILPRICE"]  = limitRow["RETAILPRICE"];
                     newRow["TRADEPRICE"]   = limitRow["TRADEPRICE"];
                     newRow["UNIT"]         = limitRow["LEASTUNIT"];
                     newRow["UNITNAME"]     = limitRow["PACKUNITNAME"];
                     newRow["STOCKNUM"]     = stockNum;
                     newRow["RETAILFEE"]    = stockNum * Convert.ToDecimal(newRow["RETAILPRICE"]);
                     newRow["TRADEFEE"]     = stockNum * Convert.ToDecimal(newRow["TRADEPRICE"]);
                     orderDt.Rows.Add(newRow);
                 }
             }
             return(orderDt);
         }
     }
     else
     {
         return(null);
     }
 }
コード例 #3
0
        /// <summary>
        /// 创建库存查询器
        /// </summary>
        /// <param name="belongSystem">所属系统(药房还是药库)</param>
        /// <returns>库存查询器</returns>
        static public StoreQuery GetQuery(string belongSystem)
        {
            switch (belongSystem)
            {
            case ConfigManager.YF_SYSTEM:
                _storeQuery = new YF_StoreQuery();
                break;

            case ConfigManager.YK_SYSTEM:
                _storeQuery = new YK_StoreQuery();
                break;

            default:
                return(null);
            }
            return(_storeQuery);
        }
コード例 #4
0
 /// <summary>
 /// 按药房库存上下限构建入库申请单
 /// </summary>
 /// <param name="newMaster">申请单表头</param>
 /// <param name="orderDt">申请单明细列表</param>
 /// <param name="_currentDeptId">申请科室</param>
 /// <param name="_currentUserId">申请人员ID</param>
 /// <param name="applyDept">出库科室</param>
 /// <param name="lowerStoreDrug">低于库存下限药品</param>
 public void BuildApplyInByStoreLimit(out YP_InMaster newMaster, out DataTable orderDt, int _currentDeptId,
                                      int _currentUserId, int applyDept, DataTable lowerStoreDrug)
 {
     try
     {
         if (lowerStoreDrug == null)
         {
             newMaster = null;
             orderDt   = null;
             return;
         }
         decimal    drugStoreNum;      //药品库存数量
         decimal    lessNum;           //还需申请数量
         decimal    batchStoreNum;     //批次库存量
         decimal    applyNum;          //总共需申请数量
         int        currentMakerDicId; //当前药品编码
         StoreQuery _storeQuery          = StoreFactory.GetQuery(ConfigManager.YF_SYSTEM);
         BillQuery  _billQuery           = BillFactory.GetQuery(ConfigManager.OP_YF_APPLYIN);
         StoreQuery _applyDeptStoreQuery = StoreFactory.GetQuery(ConfigManager.YK_SYSTEM);
         //构建一个新的入库申请单表头
         newMaster = (YP_InMaster)(this.BuildNewMaster(_currentDeptId, _currentUserId));
         orderDt   = _billQuery.LoadOrder(newMaster);
         #region 循环低于下限的药品
         for (int index = 0; index < lowerStoreDrug.Rows.Count; index++)
         {
             DataRow limitRow = lowerStoreDrug.Rows[index];
             //获取当前药品编码
             currentMakerDicId = Convert.ToInt32(limitRow["MAKERDICID"]);
             //计算需要申请入库药品数量
             applyNum = (Convert.ToDecimal(limitRow["UPPERLIMIT"]) -
                         Convert.ToDecimal(limitRow["CURRENTNUM"])) / Convert.ToDecimal(limitRow["PUNITNUM"]);
             applyNum = Math.Ceiling(applyNum);
             //按药品编码加载批次
             DataTable batchDt = _applyDeptStoreQuery.LoadBatch(currentMakerDicId, applyDept);
             if (batchDt == null)
             {
                 break;
             }
             drugStoreNum = 0;
             //判断批次总量是否满足申请要求
             for (int temp = 0; temp < batchDt.Rows.Count; temp++)
             {
                 drugStoreNum += Convert.ToDecimal(batchDt.Rows[temp]["CURRENTNUM"]);
             }
             if (drugStoreNum > applyNum)
             {
                 #region 如果满足,循环批次生成入库单明细
                 for (int temp = 0; temp < batchDt.Rows.Count; temp++)
                 {
                     lessNum       = applyNum;
                     batchStoreNum = Convert.ToDecimal(batchDt.Rows[temp]["CURRENTNUM"]);
                     if (batchStoreNum != 0)
                     {
                         DataRow newRow = orderDt.NewRow();
                         newRow["MAKERDICID"]        = limitRow["MAKERDICID"];         //厂家ID
                         newRow["CHEMNAME"]          = limitRow["CHEMNAME"];           //化学名
                         newRow["SPEC"]              = limitRow["SPEC"];               //规格
                         newRow["PRODUCTNAME"]       = limitRow["PRODUCTNAME"];        //生产厂家名
                         newRow["RETAILPRICE"]       = limitRow["RETAILPRICE"];        //零售价
                         newRow["TRADEPRICE"]        = limitRow["TRADEPRICE"];         //批发价
                         newRow["STOCKPRICE"]        = limitRow["TRADEPRICE"];         //进价
                         newRow["LEASTUNIT"]         = limitRow["PACKUNIT"];           //包装单位编码
                         newRow["UNITNAME"]          = limitRow["PACKUNITNAME"];       //包装单位
                         newRow["BATCHNUM"]          = batchDt.Rows[temp]["BATCHNUM"]; //批次号
                         newRow["DEPTID"]            = limitRow["DEPTID"];             //部门ID
                         newRow["UNITNUM"]           = limitRow["PUNITNUM"];           //单位数量
                         newRow["VALIDITYDATE"]      = Convert.ToDateTime(batchDt.Rows[temp]["VALIDITYDATE"]);
                         newRow["AUDIT_FLAG"]        = 0;
                         newRow["BILLNUM"]           = 0;
                         newRow["DELIVERNUM"]        = "";
                         newRow["InStorageID"]       = 0;
                         newRow["MasterInStorageID"] = 0;
                         newRow["REMARK"]            = "";
                         newRow["DEFSTOCKPRICE"]     = limitRow["TRADEPRICE"];
                         newRow["RecScale"]          = 0.0;
                         //批次数量大于还需申请数量
                         if (batchStoreNum >= lessNum)
                         {
                             if (lessNum < 1)
                             {
                                 break;
                             }
                             else
                             {
                                 //lessNum = Math.Ceiling(lessNum);
                                 newRow["INNUM"]     = lessNum;                                            //入库数量
                                 newRow["TRADEFEE"]  = lessNum * Convert.ToDecimal(newRow["TRADEPRICE"]);  //批发金额
                                 newRow["RETAILFEE"] = lessNum * Convert.ToDecimal(newRow["RETAILPRICE"]); //零售金额
                                 newRow["STOCKFEE"]  = newRow["TRADEFEE"];                                 //进货金额
                                 orderDt.Rows.Add(newRow);
                                 break;
                             }
                         }
                         //批次数量小于还需申请数量
                         else
                         {
                             newRow["INNUM"]     = batchStoreNum;
                             newRow["TRADEFEE"]  = lessNum * Convert.ToDecimal(newRow["TRADEPRICE"]);  //批发金额
                             newRow["RETAILFEE"] = lessNum * Convert.ToDecimal(newRow["RETAILPRICE"]); //零售金额
                             newRow["STOCKFEE"]  = newRow["TRADEFEE"];
                             lessNum             = applyNum - batchStoreNum;                           //进货金额
                             orderDt.Rows.Add(newRow);
                         }
                     }
                 }
                 #endregion 如果满足,循环批次生成入库单明细
             }
         }
         #endregion 循环低于下限的药品
     }
     catch (Exception error)
     {
         throw error;
     }
 }