/// <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.YK_ACCOUNT);

                AccountFactory.GetQuery(ConfigManager.YK_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;
            }
        }
        /// <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_CheckMaster masterCheck = (YP_CheckMaster)billMaster;
                ComputeMasterFee(masterCheck, listOrder);
                oleDb.BeginTransaction();
                //声明操作对象
                HIS.DAL.YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                YP_CheckOrder checkOrder = new YP_CheckOrder();
                BindEntity <HIS.Model.YP_CheckMaster> .CreateInstanceDAL(oleDb, Tables.YF_CHECKMASTER).Update(masterCheck);

                foreach (BillOrder order in listOrder)
                {
                    checkOrder = (YP_CheckOrder)order;
                    BindEntity <HIS.Model.YP_CheckOrder> .CreateInstanceDAL(oleDb, Tables.YF_CHECKORDER).Update(checkOrder);
                }
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #3
0
 private void dgrdCheckMaster_CurrentCellChanged(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.WaitCursor();
         if (dgrdCheckMaster.CurrentCell != null)
         {
             int currentIndex = dgrdCheckMaster.CurrentCell.RowIndex;
             _currentMaster            = GetCheckMasterFromDt(_masterDt.DefaultView.ToTable(), currentIndex);
             _orderDt                  = _billQuery.LoadOrder(_currentMaster);
             dgrdCheckOrder.DataSource = _orderDt;
         }
         else
         {
             dgrdCheckOrder.DataSource = null;
             _currentMaster            = null;
         }
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message);
     }
     finally
     {
         this.Cursor = DefaultCursor;
     }
 }
Beispiel #4
0
        /// <summary>
        /// 根据单据信息构造台帐信息
        /// </summary>
        /// <param name="billMaster">单据头</param>
        /// <param name="billOrder">单据明细信息</param>
        /// <param name="storeNum">库存处理后药品库存信息</param>
        /// <param name="accountYear">会计年份</param>
        /// <param name="accountMonth">会计月份</param>
        /// <param name="smallUnit">基本单位</param>
        /// <returns>台帐信息</returns>
        override protected YP_Account BuildAccount(BillMaster billMaster, BillOrder billOrder, decimal storeNum,
                                                   int accountYear, int accountMonth, int smallUnit)
        {
            YP_Account     account = new YP_Account();
            YP_CheckMaster master  = (YP_CheckMaster)billMaster;
            YP_CheckOrder  order   = (YP_CheckOrder)billOrder;

            account.AccountYear  = accountYear;
            account.AccountMonth = accountMonth;;
            account.AccountType  = 2;
            account.Balance_Flag = 0;
            account.BillNum      = master.BillNum;
            account.OpType       = master.OpType;
            account.DeptID       = master.DeptID;
            account.LeastUnit    = smallUnit;
            account.UnitNum      = order.UnitNum;
            account.MakerDicID   = order.MakerDicID;
            account.RegTime      = master.AuditTime;
            account.RetailPrice  = order.RetailPrice;
            account.StockPrice   = order.TradePrice;
            account.OrderID      = order.CheckOrderID;
            if (order.CheckNum - order.FactNum > 0)
            {
                account.LenderNum = order.CheckNum - order.FactNum;
                account.LenderFee = Math.Abs(order.CKRetailFee - order.FTRetailFee);
            }
            else
            {
                account.DebitNum = order.FactNum - order.CheckNum;
                account.DebitFee = Math.Abs(order.CKRetailFee - order.FTRetailFee);
            }
            account.OverNum = storeNum;
            return(account);
        }
Beispiel #5
0
 private void tsrbtnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         YP_CheckMaster master      = new YP_CheckMaster();
         int            auditNum    = 0;
         string         strAuditNum = GWMHIS.BussinessLogicLayer.Forms.DlgInputBoxStatic.InputBox("", "请输入要打印的审核单号", "");
         if (strAuditNum != "" && Int32.TryParse(strAuditNum, out auditNum))
         {
             if (_belongSystem == ConfigManager.YF_SYSTEM)
             {
                 master.OpType = ConfigManager.OP_YF_CHECK;
             }
             else
             {
                 master.OpType = ConfigManager.OP_YK_CHECK;
             }
             master.AuditNum = auditNum;
             master.DeptID   = (int)_currentDeptId;
             string startPath = Application.StartupPath + "\\report\\药品盘点单据.grf";
             PrintFactory.GetPrinter(ConfigManager.OP_YK_CHECK).PrintBill(master, null, startPath,
                                                                          (int)_currentUserId);
         }
         else
         {
             throw new Exception("盘点单号格式不正确,请重新输入");
         }
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message);
     }
 }
Beispiel #6
0
 /// <summary>
 /// 从盘点表头信息表中读取盘点表头对象
 /// </summary>
 /// <param name="dtTable">盘点表头信息表</param>
 /// <param name="index"> 对应行记录索引</param>
 /// <returns>读取的盘点表头对象</returns>
 private YP_CheckMaster GetCheckMasterFromDt(DataTable dtTable, int index)
 {
     try
     {
         if (dtTable.Rows.Count < index || dtTable.Rows.Count == 0)
         {
             return(null);
         }
         YP_CheckMaster currentMaster = new YP_CheckMaster();
         HIS.SYSTEM.PubicBaseClasses.ApiFunction.DataTableToObject(dtTable, index, currentMaster);
         return(currentMaster);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
        /// <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_CheckMaster masterCheck = (YP_CheckMaster)billMaster;
                ComputeMasterFee(masterCheck, listOrder);
                oleDb.BeginTransaction();
                YP_CheckMaster inDBMaster = BindEntity <YP_CheckMaster> .CreateInstanceDAL(oleDb,
                                                                                           Tables.YK_CHECKMASTER).GetModel(masterCheck.MasterCheckID);

                if (inDBMaster.Del_Flag == 1)
                {
                    throw new Exception("当前单据已经被强制清除,无法保证盘存数量的正确性,请重新录入新的盘点单");
                }
                //声明操作对象
                HIS.DAL.YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                YP_CheckOrder checkOrder = new YP_CheckOrder();
                //获取盘点单据号
                int billNum = (ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YK_CHECK, masterCheck.DeptID)).BillNum;
                masterCheck.BillNum  = billNum;
                masterCheck.Del_Flag = 0;
                BindEntity <HIS.Model.YP_CheckMaster> .CreateInstanceDAL(oleDb, Tables.YK_CHECKMASTER).Update(masterCheck);

                foreach (YP_CheckOrder order in listOrder)
                {
                    //遍历DataTable取出明细记录并设置记录的值
                    checkOrder = (YP_CheckOrder)order;
                    checkOrder.MasterCheckID = masterCheck.MasterCheckID;
                    checkOrder.DeptID        = masterCheck.DeptID;
                    checkOrder.BillNum       = masterCheck.BillNum;
                    checkOrder.BillTime      = masterCheck.RegTime;
                    //依次添加明细记录
                    BindEntity <HIS.Model.YP_CheckOrder> .CreateInstanceDAL(oleDb, Tables.YK_CHECKORDER).Add(checkOrder);
                }
                //更新盘点标识位
                ConfigManager.BeginCheck((long)(masterCheck.DeptID));
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #8
0
 private void tsrbtnRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         LoadData();
         if (_masterDt.Rows.Count >= 1)
         {
             dgrdCheckMaster_CurrentCellChanged(null, null);
         }
         else
         {
             _currentMaster = null;
         }
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message);
     }
 }
 /// <summary>
 /// 清除库房盘点状态
 /// </summary>
 /// <param name="master"></param>
 /// <param name="_billQuery"></param>
 /// <param name="_billProcessor"></param>
 /// <param name="belongSystem"></param>
 public static void StopCheckStatus(YP_CheckMaster master, BillQuery _billQuery,
                                    BillProcessor _billProcessor, string belongSystem)
 {
     try
     {
         _billProcessor.DelBill(master);
         oleDb.BeginTransaction();
         if (!_billQuery.CheckBill_ExistsNotAudit(master.MasterCheckID, belongSystem))
         {
             EndCheck(master.DeptID);
         }
         oleDb.CommitTransaction();
     }
     catch (Exception error)
     {
         oleDb.RollbackTransaction();
         throw error;
     }
 }
        /// <summary>
        /// 创建盘点表头
        /// </summary>
        /// <param name="deptId">药剂科室ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns>盘点表头</returns>
        public override HIS.Model.BillMaster BuildNewMaster(long deptId, long userId)
        {
            try
            {
                YP_CheckMaster master = new YP_CheckMaster();
                master.Audit_Flag    = 0;
                master.AuditPeopleID = 0;
                master.Del_Flag      = 0;
                master.DeptID        = Convert.ToInt32(deptId);
                master.RegPeopleID   = Convert.ToInt32(userId);
                master.RegTime       = XcDate.ServerDateTime;
                master.BillNum       = 0;
                BindEntity <HIS.Model.YP_CheckMaster> .CreateInstanceDAL(oleDb, Tables.YF_CHECKMASTER).Add(master);

                return(master);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
        /// <summary>
        /// 删除盘点单据
        /// </summary>
        /// <param name="billMaster">盘点单表头</param>
        public override void DelBill(BillMaster billMaster)
        {
            try
            {
                YP_CheckMaster master = (YP_CheckMaster)billMaster;
                oleDb.BeginTransaction();
                HIS.DAL.YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                IBaseDAL <YP_CheckMaster> checkMaster = BindEntity <HIS.Model.YP_CheckMaster> .CreateInstanceDAL(oleDb,
                                                                                                                 Tables.YF_CHECKMASTER);

                checkMaster.Update(BLL.Tables.yf_checkmaster.MASTERCHECKID + oleDb.EuqalTo() + master.MasterCheckID,
                                   BLL.Tables.yf_checkmaster.DEL_FLAG + oleDb.EuqalTo() + "1");
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                oleDb.RollbackTransaction();
                throw error;
            }
        }
Beispiel #12
0
 /// <summary>
 /// 加载药房盘点单明细
 /// </summary>
 /// <param name="billMaster">单据头表</param>
 /// <returns></returns>
 public override DataTable LoadOrder(BillMaster billMaster)
 {
     try
     {
         YP_CheckMaster masterCheck = (YP_CheckMaster)billMaster;
         HIS.DAL.YP_Dal ypDal       = new YP_Dal();
         ypDal._oleDb = oleDb;
         if (masterCheck != null)
         {
             return(ypDal.YK_Checkorder_GetListByMaster(masterCheck.MasterCheckID));
         }
         else
         {
             return(ypDal.YK_Checkorder_GetListByMaster(0));
         }
     }
     catch (Exception error)
     {
         throw error;
     }
 }
 /// <summary>
 /// 计算盘点单盈亏金额合计
 /// </summary>
 /// <param name="checkMaster">盘点头</param>
 /// <param name="listOrder">盘点明细</param>
 protected void ComputeMasterFee(YP_CheckMaster checkMaster, List <BillOrder> listOrder)
 {
     checkMaster.MoreRetailFee = 0;
     checkMaster.MoreTradeFee  = 0;
     checkMaster.LessRetailFee = 0;
     checkMaster.LessTradeFee  = 0;
     foreach (YP_CheckOrder order in listOrder)
     {
         //盘盈
         if (order.FactNum < order.CheckNum)
         {
             checkMaster.MoreRetailFee += (order.CKRetailFee - order.FTRetailFee);
             checkMaster.MoreTradeFee  += (order.CKTradeFee - order.FTTradeFee);
         }
         //盘亏
         else
         {
             checkMaster.LessRetailFee += (order.FTRetailFee - order.CKRetailFee);
             checkMaster.LessTradeFee  += (order.FTTradeFee - order.CKTradeFee);
         }
     }
 }
        /// <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
            {
                //更改标识位
                HIS.DAL.YP_Dal ypDal = new YP_Dal();
                ypDal._oleDb = oleDb;
                //审核表头对象
                List <BillOrder> totalListOrder = new List <BillOrder>();
                string           str            = Tables.yf_checkmaster.AUDIT_FLAG + oleDb.EuqalTo() + "0" + oleDb.And() +
                                                  Tables.yf_checkmaster.DEL_FLAG + oleDb.NotEqualTo() + "1" + oleDb.And() +
                                                  Tables.yf_checkmaster.DEPTID + oleDb.EuqalTo() + auditDeptID.ToString();
                List <YP_CheckMaster> listMaster = BindEntity <HIS.Model.YP_CheckMaster> .CreateInstanceDAL(oleDb,
                                                                                                            Tables.YF_CHECKMASTER).GetListArray(str);

                if (listMaster.Count <= 0)
                {
                    ConfigManager.EndCheck((int)auditerID);
                    throw new Exception("没有单据需要审核!");
                }
                DateTime _currentTime = XcDate.ServerDateTime;
                int      groupNum     = (ypDal.YP_Bill_GetBillNum(ConfigManager.OP_YF_AUDITCHECK,
                                                                  auditDeptID)).BillNum;
                foreach (YP_CheckMaster checkMaster in listMaster)
                {
                    if (checkMaster.BillNum == 0)
                    {
                        throw new Exception("当前还有单据在盘点中,请确认所有盘点单据都保存成功");
                    }
                    checkMaster.AuditNum      = groupNum;
                    checkMaster.Audit_Flag    = 1;
                    checkMaster.AuditPeopleID = Convert.ToInt32(auditerID);
                    checkMaster.AuditTime     = _currentTime;
                    checkMaster.DeptID        = Convert.ToInt32(auditDeptID);
                    //读取审核表头对象对应的审核明细链表
                    str = Tables.yf_checkorder.MASTERCHECKID + oleDb.EuqalTo() + checkMaster.MasterCheckID;
                    List <YP_CheckOrder> listOrder = BindEntity <HIS.Model.YP_CheckOrder> .CreateInstanceDAL(oleDb,
                                                                                                             Tables.YF_CHECKORDER).GetListArray(str);

                    //构建盘点汇总明细表
                    AddOrderListByMakerId(totalListOrder, listOrder);
                }
                oleDb.BeginTransaction();
                foreach (YP_CheckMaster checkMaster in listMaster)
                {
                    BindEntity <YP_CheckMaster> .CreateInstanceDAL(oleDb, BLL.Tables.YF_CHECKMASTER).Update(checkMaster);

                    string nameAndValue = Tables.yf_checkorder.AUDIT_FLAG + oleDb.EuqalTo() + "1";
                    BindEntity <HIS.Model.YP_CheckOrder> .CreateInstanceDAL(oleDb,
                                                                            Tables.YF_CHECKORDER).Update(BLL.Tables.yf_checkorder.MASTERCHECKID + oleDb.EuqalTo() + checkMaster.MasterCheckID,
                                                                                                         nameAndValue);
                }
                YP_CheckMaster newMaster = new YP_CheckMaster();
                newMaster.AuditTime = _currentTime;
                newMaster.DeptID    = Convert.ToInt32(auditDeptID);
                newMaster.BillNum   = groupNum;
                newMaster.OpType    = ConfigManager.OP_YF_AUDITCHECK;
                Hashtable storeTable = StoreFactory.GetProcessor(ConfigManager.OP_YF_CHECK).ChangeStoreNum(newMaster, totalListOrder);
                AccountFactory.GetWriter(ConfigManager.OP_YF_CHECK).WriteAccount(newMaster, totalListOrder, storeTable);
                ConfigManager.EndCheck((int)auditDeptID);
                oleDb.CommitTransaction();
            }
            catch (Exception error)
            {
                if (oleDb.IsInTransaction)
                {
                    oleDb.RollbackTransaction();
                }
                throw error;
            }
        }