예제 #1
0
        /// <summary>
        ///  添加订单的明细信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDetailAdd_Click(object sender, EventArgs e)
        {
            try
            {
                FormDrugForSalesSelector selForm = new FormDrugForSalesSelector(Guid.Empty);
                if (selForm.ShowDialog() == DialogResult.OK)
                {
                    _drugInventoryRecordlList = selForm.result;
                    if (_retailOrderDetailList == null)
                    {
                        _retailOrderDetailList = new List <RetailOrderDetail>();
                    }
                    int index = _retailOrderDetailList.Count;
                    foreach (DrugInventoryRecord drugInventoryRecord in _drugInventoryRecordlList)
                    {
                        RetailOrderDetail rod = new RetailOrderDetail();
                        int pieNum            = drugInventoryRecord.DrugInfo.PiecemealNumber;
                        rod.Id                    = Guid.NewGuid();
                        rod.IsDismanting          = false;
                        rod.MeasurementUnit       = drugInventoryRecord.DrugInfo.DictionaryMeasurementUnitCode;
                        rod.UnitPrice             = drugInventoryRecord.DrugInfo.Price;
                        rod.productName           = drugInventoryRecord.DrugInfo.ProductName;
                        rod.productCode           = drugInventoryRecord.DrugInfo.Code;
                        rod.BatchNumber           = drugInventoryRecord.BatchNumber;
                        rod.Description           = drugInventoryRecord.Decription;
                        rod.DrugInventoryRecordID = drugInventoryRecord.Id;
                        rod.FactoryName           = drugInventoryRecord.DrugInfo.FactoryName;
                        rod.SpecificationCode     = drugInventoryRecord.DrugInfo.SpecialDrugCategoryCode;
                        rod.PruductDate           = drugInventoryRecord.PruductDate;
                        rod.OutValidDate          = drugInventoryRecord.OutValidDate;
                        if (pieNum > 0)
                        {
                            rod.DismantingUnitPrice = Math.Round(drugInventoryRecord.DrugInfo.Price / pieNum, 2);
                        }
                        rod.ActualUnitPrice           = 0;
                        rod.ActualDismantingUnitPrice = 0;
                        rod.DismantingAmount          = 0;
                        rod.Amount     = 0;
                        rod.Index      = index;
                        rod.TotalMoney = Math.Round(rod.UnitPrice * rod.Amount * rod.Discount / 100, 2);
                        rod.Discount   = 100;
                        _retailOrderDetailList.Add(rod);
                        index++;
                    }

                    this.dgvDrugDetailList.DataSource = _retailOrderDetailList;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加零售单明细信息失败!!!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Error(ex);
            }
        }
예제 #2
0
        /// <summary>
        /// 根据零售单获取更新后的库存实体
        /// </summary>
        /// <param name="rod"></param>
        /// <returns></returns>
        protected internal DrugInventoryRecord GetRetailLeftDrugInventoryRecord(RetailOrderDetail rod)
        {
            Guid    drugInventoryID = rod.DrugInventoryRecordID;
            decimal consumeQty      = rod.Amount;
            //获取药物库存实体
            DrugInventoryRecord drugInventory = BusinessHandlerFactory.DrugInventoryRecordBusinessHandler.Get(drugInventoryID);
            int piecemealNumber = drugInventory.DrugInfo.PiecemealNumber;

            #region DrugInventoryRecord  药物实体库存处理
            if (rod.Amount < drugInventory.CurrentInventoryCount)
            {
                if (rod.IsDismanting)
                {
                    //当前拆零数量是否满足该条零售的拆零数量
                    //如果拆零数量不足,则再拆一个单位
                    if (drugInventory.DismantingAmount < rod.DismantingAmount)
                    {
                        drugInventory.CurrentInventoryCount = drugInventory.CurrentInventoryCount - 1;
                        drugInventory.DismantingAmount      = drugInventory.DismantingAmount + piecemealNumber;
                    }
                    //存库存表的当前可用拆零数量扣掉该零售拆零数量
                    drugInventory.DismantingAmount = drugInventory.DismantingAmount - rod.DismantingAmount;
                    //将零售拆零数量累加到可用库存的拆零零售数量
                    drugInventory.RetailDismantingAmount = drugInventory.RetailDismantingAmount + rod.DismantingAmount;

                    if (piecemealNumber > 0)
                    {
                        //如果已售的零售数量大于一个单位,则需要装包
                        if (drugInventory.RetailDismantingAmount >= piecemealNumber)
                        {
                            drugInventory.RetailCount            = drugInventory.RetailCount + drugInventory.RetailDismantingAmount / piecemealNumber;
                            drugInventory.RetailDismantingAmount = drugInventory.RetailDismantingAmount % piecemealNumber;
                        }
                    }
                }
                else
                {
                    //存库存表的当前可用库存扣掉该零售数量
                    drugInventory.CurrentInventoryCount = drugInventory.CurrentInventoryCount - rod.Amount;
                    //将零售数量累加到可用库存的零售数量
                    drugInventory.RetailCount = drugInventory.RetailCount + rod.Amount;
                }
            }
            else
            {
                throw new Exception("库存数量不足");
            }
            #endregion

            return(drugInventory);
        }
        /// <summary>
        /// 根据零售退货单获取更新后的库存实体
        /// </summary>
        /// <param name="rod"></param>
        /// <returns></returns>
        protected internal InventoryRecord GetRetailReturnLeftDrugInventoryRecord(RetailOrderDetail rod, Guid drugInfoID, int piecemealNumber)
        {
            Guid    drugInventoryID = rod.DrugInventoryRecordID;
            decimal returnQty       = rod.ReturnAmount;

            //获取药物库存实体

            InventoryRecord Inventory = this.Get(drugInventoryID);

            if (Inventory != null)
            {
                #region DrugInventoryRecord  药物实体库存处理

                if (rod.IsDismanting)
                {
                    //将退库的零售拆零数量累加到药品库存的待售零售拆零数量上
                    Inventory.DismantingAmount += returnQty;

                    if (piecemealNumber > 0)
                    {
                        //如果待售零售拆零数量大于一个单位,则需要装包
                        if (Inventory.DismantingAmount >= piecemealNumber)
                        {
                            Inventory.CurrentInventoryCount += Inventory.DismantingAmount / piecemealNumber;
                            Inventory.DismantingAmount       = Inventory.DismantingAmount % piecemealNumber;
                        }
                    }

                    //将退库的零售拆零数量从已售的拆零零售数量里扣除
                    //已售拆零数量是不够扣除拆零退货数量,则从已售零售里拆包
                    if (Inventory.RetailDismantingAmount < returnQty)
                    {
                        Inventory.RetailCount            -= 1;
                        Inventory.RetailDismantingAmount += piecemealNumber;
                    }
                    Inventory.RetailDismantingAmount -= returnQty;
                }
                else
                {
                    //存库存表的当前可用库存加上改退货数量
                    Inventory.CurrentInventoryCount += returnQty;

                    //将已经销售的零售数量累减去退货数量
                    Inventory.RetailCount -= returnQty;
                }

                #endregion
            }
            return(Inventory);
        }
        /// <summary>
        /// 根据零售单获取更新后的库存实体
        /// </summary>
        /// <param name="rod"></param>
        /// <returns></returns>
        protected internal InventoryRecord GetRetailLeftDrugInventoryRecord(RetailOrderDetail rod, Guid drugInfoID, int piecemealNumber)
        {
            //获取库存实体
            InventoryRecord Inventory = BusinessHandlerFactory.InventoryRecordBusinessHandler.GetInventoryRecordByDrugInfoID(drugInfoID);

            if (Inventory != null)
            {
                if (Inventory.CurrentInventoryCount < rod.Amount)
                {
                    if (rod.IsDismanting)
                    {
                        //当前拆零数量是否满足该条零售的拆零数量
                        //如果拆零数量不足,则再拆一个单位
                        if (Inventory.DismantingAmount < rod.DismantingAmount)
                        {
                            Inventory.CurrentInventoryCount = Inventory.CurrentInventoryCount - 1;
                            Inventory.DismantingAmount      = Inventory.DismantingAmount + piecemealNumber;
                        }
                        //存库存表的当前可用拆零数量扣掉该零售拆零数量
                        Inventory.DismantingAmount = Inventory.DismantingAmount - rod.DismantingAmount;
                        //将零售拆零数量累加到可用库存的拆零零售数量
                        Inventory.RetailDismantingAmount = Inventory.RetailDismantingAmount + rod.DismantingAmount;

                        if (piecemealNumber > 0)
                        {
                            //如果已售的零售数量大于一个单位,则需要装包
                            if (Inventory.RetailDismantingAmount >= piecemealNumber)
                            {
                                Inventory.RetailCount            = Inventory.RetailCount + Inventory.RetailDismantingAmount / piecemealNumber;
                                Inventory.RetailDismantingAmount = Inventory.RetailDismantingAmount % piecemealNumber;
                            }
                        }
                    }
                    else
                    {
                        //存库存表的当前可用库存扣掉该零售数量
                        Inventory.CurrentInventoryCount = Inventory.CurrentInventoryCount - rod.Amount;
                        //将零售数量累加到可用库存的零售数量
                        Inventory.RetailCount = Inventory.RetailCount + rod.Amount;
                    }
                }
                return(Inventory);
            }
            else
            {
                return(null);

                throw new Exception("库存数量不足");
            }
        }
예제 #5
0
        /// <summary>
        /// 根据零售退货单获取更新后的库存实体
        /// </summary>
        /// <param name="rod"></param>
        /// <returns></returns>
        protected internal DrugInventoryRecord GetRetailReturnLeftDrugInventoryRecord(RetailOrderDetail rod)
        {
            Guid    drugInventoryID = rod.DrugInventoryRecordID;
            decimal returnQty       = rod.ReturnAmount;

            //获取药物库存实体
            DrugInventoryRecord drugInventory = BusinessHandlerFactory.DrugInventoryRecordBusinessHandler.Get(drugInventoryID);

            int piecemealNumber = drugInventory.DrugInfo.PiecemealNumber;

            #region DrugInventoryRecord  药物实体库存处理

            if (rod.IsDismanting)
            {
                //将退库的零售拆零数量累加到药品库存的待售零售拆零数量上
                drugInventory.DismantingAmount += returnQty;

                if (piecemealNumber > 0)
                {
                    //如果待售零售拆零数量大于一个单位,则需要装包
                    if (drugInventory.DismantingAmount >= piecemealNumber)
                    {
                        drugInventory.CurrentInventoryCount += drugInventory.DismantingAmount / piecemealNumber;
                        drugInventory.DismantingAmount       = drugInventory.DismantingAmount % piecemealNumber;
                    }
                }

                //将退库的零售拆零数量从已售的拆零零售数量里扣除
                //已售拆零数量是不够扣除拆零退货数量,则从已售零售里拆包
                if (drugInventory.RetailDismantingAmount < returnQty)
                {
                    drugInventory.RetailCount            -= 1;
                    drugInventory.RetailDismantingAmount += piecemealNumber;
                }
                drugInventory.RetailDismantingAmount -= returnQty;
            }
            else
            {
                //存库存表的当前可用库存加上改退货数量
                drugInventory.CurrentInventoryCount += returnQty;

                //将已经销售的零售数量累减去退货数量
                drugInventory.RetailCount -= returnQty;
            }

            #endregion
            return(drugInventory);
        }