/// <summary>
        /// This generates picklist for everything in the receivepallet entry.
        /// </summary>
        /// <param name="receiveDoc"></param>
        /// <param name="receivePallet"></param>
        /// <param name="order"></param>
        /// <param name="picklist"></param>
        /// <returns></returns>
        public PickListDetail CreatePicklistDetailWithOrder(ReceiveDoc receiveDoc, ReceivePallet receivePallet, Order order, PickList picklist)
        {
            double?      cost         = null;
            decimal      pack         = receivePallet.Balance / receiveDoc.QtyPerPack;
            OrderService orderService = new OrderService();

            orderService.CreateOrderDetail(receiveDoc, order, pack);
            if (!receiveDoc.IsColumnNull("Cost"))
            {
                cost = receiveDoc.Cost;
            }
            PickListDetail pickListDetail = PickListDetail.GeneratePickListDetail(pack, cost, receiveDoc.ID,
                                                                                  receiveDoc.ManufacturerId,
                                                                                  receivePallet.ID,
                                                                                  receiveDoc.QtyPerPack,
                                                                                  receiveDoc.StoreID, receiveDoc.UnitID,
                                                                                  receiveDoc.ItemID, picklist.ID,
                                                                                  receivePallet.PalletID,
                                                                                  receiveDoc.ExpDate.ToString(),
                                                                                  receiveDoc.BatchNo);

            ReceivePallet.ReserveQty(pack, receivePallet.ID);

            return(pickListDetail);
        }
Beispiel #2
0
        public void PickList(Resolver resolver)
        {
            PickList pickList = pickListMgr.CheckAndLoadPickList(resolver.Code);

            pickList.PickListDetails = new List <PickListDetail>();
            if (resolver.Transformers != null)
            {
                foreach (Transformer transformer in resolver.Transformers)
                {
                    PickListDetail pickListDetail = pickListDetailMgr.LoadPickListDetail(transformer.Id, true);
                    if (transformer != null)
                    {
                        foreach (TransformerDetail transformerDetail in transformer.TransformerDetails)
                        {
                            if (transformerDetail != null && transformerDetail.HuId != null && transformerDetail.HuId != string.Empty &&
                                transformerDetail.CurrentQty != 0)
                            {
                                PickListResult pickListResult = new PickListResult();
                                //pickListResult.LocationLotDetail = locationLotDetailMgr.LoadLocationLotDetail(transformerDetail.LocationLotDetId);
                                pickListResult.LocationLotDetail = locationLotDetailMgr.CheckLoadHuLocationLotDetail(transformerDetail.HuId);
                                pickListResult.PickListDetail    = pickListDetail;
                                pickListResult.Qty = transformerDetail.CurrentQty * pickListDetail.OrderLocationTransaction.UnitQty;
                                pickListDetail.AddPickListResult(pickListResult);
                            }
                        }
                    }
                    pickList.AddPickListDetail(pickListDetail);
                }
            }
            pickListMgr.DoPick(pickList, resolver.UserCode);
            resolver.Result       = languageMgr.TranslateMessage("MasterData.PickList.Pick.Successfully", resolver.UserCode, resolver.Code);
            resolver.Transformers = null;
            resolver.Command      = BusinessConstants.CS_BIND_VALUE_TRANSFORMER;
        }
Beispiel #3
0
        public PickListDetail LoadPickListDetail(int pickListDetailId, bool includePickListResult)
        {
            PickListDetail pickListDetail = base.LoadPickListDetail(pickListDetailId);

            if (includePickListResult && pickListDetail != null && pickListDetail.PickListResults != null && pickListDetail.PickListResults.Count > 0)
            {
            }
            return(pickListDetail);
        }
Beispiel #4
0
    public void DoPick()
    {
        if (ConfirmEvent != null)
        {
            int      resultCount = 0;
            PickList pickList    = ThePickListMgr.LoadPickList(this.PickListNo);
            pickList.PickListDetails = new List <PickListDetail>();
            foreach (GridViewRow row in GV_List.Rows)
            {
                Label lblLoc = (Label)row.FindControl("lblLoc");

                HiddenField hfId      = (HiddenField)row.FindControl("hfId");
                Hu_HuInput  ucHuInput = (Hu_HuInput)row.FindControl("ucHuInput");

                PickListDetail pickListDetail = ThePickListDetailMgr.LoadPickListDetail(int.Parse(hfId.Value), true);

                IList <Hu> huList = ucHuInput.GetHuList();
                if (huList != null && huList.Count > 0)
                {
                    foreach (Hu hu in huList)
                    {
                        IList <LocationLotDetail> locationLotDetailList = TheLocationLotDetailMgr.GetHuLocationLotDetail(lblLoc.Text.Trim(), hu.HuId);
                        if (locationLotDetailList != null && locationLotDetailList.Count > 0)
                        {
                            PickListResult pickListResult = new PickListResult();
                            pickListResult.LocationLotDetail = locationLotDetailList[0];
                            pickListResult.PickListDetail    = pickListDetail;
                            pickListResult.Qty = hu.Qty * pickListDetail.OrderLocationTransaction.UnitQty;
                            pickListDetail.AddPickListResult(pickListResult);

                            resultCount++;
                        }
                    }
                }
                pickList.AddPickListDetail(pickListDetail);
            }

            if (resultCount == 0)
            {
                ShowErrorMessage("MasterData.No.PickListResult");
                return;
            }
            try
            {
                ThePickListMgr.DoPick(pickList, this.CurrentUser);
                ShowSuccessMessage("MasterData.PickList.Pick.Successfully", pickList.PickListNo);
                ConfirmEvent(this.PickListNo, null);
            }
            catch (BusinessErrorException ex)
            {
                ShowErrorMessage(ex);
            }
        }
    }
        /// <summary>
        /// Adds a new delete log
        /// </summary>
        /// <param name="deletedPickListDetail">The PickListDetail object to be deleted</param>
        /// <param name="deletedByUser">The user performing the deletion</param>
        public static void AddNewLog(PickListDetail deletedPickListDetail, int deletedByUser)
        {
            var pickListLog = new PickListDetailDeleted();
                CheckAndRemoveIfPreviouslyDeleted(deletedPickListDetail.PickListID);

                pickListLog.AddNew();
                foreach (DataColumn col in deletedPickListDetail.DefaultView.Table.Columns)
                {
                    pickListLog.SetColumn((col.ColumnName.Equals("ID") ? "PickListDetailDeletedID" : col.ColumnName), deletedPickListDetail.GetColumn(col.ColumnName));
                }
                pickListLog.DeletedBy = deletedByUser;
                pickListLog.DateDeleted = DateTimeHelper.ServerDateTime;
                pickListLog.Save();
        }
        /// <summary>
        /// Adds a new delete log
        /// </summary>
        /// <param name="deletedPickListDetail">The PickListDetail object to be deleted</param>
        /// <param name="deletedByUser">The user performing the deletion</param>
        public static void AddNewLog(PickListDetail deletedPickListDetail, int deletedByUser)
        {
            var pickListLog = new PickListDetailDeleted();

            CheckAndRemoveIfPreviouslyDeleted(deletedPickListDetail.PickListID);

            pickListLog.AddNew();
            foreach (DataColumn col in deletedPickListDetail.DefaultView.Table.Columns)
            {
                pickListLog.SetColumn((col.ColumnName.Equals("ID") ? "PickListDetailDeletedID" : col.ColumnName), deletedPickListDetail.GetColumn(col.ColumnName));
            }
            pickListLog.DeletedBy   = deletedByUser;
            pickListLog.DateDeleted = DateTimeHelper.ServerDateTime;
            pickListLog.Save();
        }
        /// <summary>
        /// Handles the Click event of the btnPrint control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void btnPrint_Click(object sender, EventArgs e)
        {
            DataRow        dr      = gridViewTransaction.GetFocusedDataRow();
            PickList       pl      = new PickList();
            PickListDetail pld     = new PickListDetail();
            int            orderId = Convert.ToInt32(dr["OrderID"]);
            DataView       dv      = pl.GetPickedOrderDetailForOrder(_stvLogIdChosen.Value, false);

            XtraReport xtraReport = RePrintSTV(dv, orderId, pl, _stvLogIdChosen, false, false);

            if (xtraReport != null)
            {
                xtraReport.PrintDialog();
            }
        }
Beispiel #8
0
        /// <summary>
        /// 拣货
        /// </summary>
        /// <param name="pickListDetail"></param>
        /// <returns></returns>
        public static TransformerDetail ConvertPickListDetailToTransformerDetail(PickListDetail pickListDetail)
        {
            TransformerDetail transformerDetail = ConvertOrderLocationTransactionToTransformerDetail(pickListDetail.OrderLocationTransaction);

            transformerDetail.HuId           = pickListDetail.HuId;
            transformerDetail.LotNo          = pickListDetail.LotNo;
            transformerDetail.Qty            = pickListDetail.Qty;
            transformerDetail.StorageBinCode = pickListDetail.StorageBin == null ? string.Empty : pickListDetail.StorageBin.Code;

            if (pickListDetail.PickListResults != null && pickListDetail.PickListResults.Count > 0)
            {
                foreach (PickListResult pickListResult in pickListDetail.PickListResults)
                {
                    transformerDetail.Qty -= pickListResult.Qty;
                }
            }
            return(transformerDetail);
        }
Beispiel #9
0
 public async Task <int> InsertPickListDetail(PickListDetail _temp)
 {
     try
     {
         dataBase.PickListDetails.Add(new PickListDetail
         {
             LineID       = _temp.LineID,
             PickListID   = _temp.PickListID,
             CustomerID   = _temp.CustomerID,
             CustomerName = _temp.CustomerName,
         });
         Console.WriteLine("ok");
         return(await dataBase.SaveChangesAsync());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(0);
     }
 }
Beispiel #10
0
 protected void GV_List_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         PickListDetail         pickListDetail     = (PickListDetail)e.Row.DataItem;
         Hu_HuInput             ucHuInput          = (Hu_HuInput)e.Row.FindControl("ucHuInput");
         TextBox                tbShipQty          = (TextBox)e.Row.FindControl("tbShipQty");
         IList <PickListResult> pickListResultList = ThePickListResultMgr.GetPickListResult(pickListDetail);
         if (pickListResultList != null && pickListResultList.Count > 0)
         {
             foreach (PickListResult pickListResult in pickListResultList)
             {
                 string huId  = pickListResult.LocationLotDetail.Hu.HuId;
                 Hu     newHu = TheHuMgr.LoadHu(huId);
                 newHu.Qty = pickListResult.Qty;
                 ucHuInput.HuInput(newHu);
                 tbShipQty.Text = ucHuInput.SumQty().ToString("F2");
             }
         }
     }
 }
Beispiel #11
0
        public void CreateDetailTransactionsForErrorCorrection(Order order, BLL.PickList picklist,
                                                               Issue stvLog, int receiptPalletId, int receiptID, User user, DateTime convertedEthDate
                                                               , int newItemId, int newUnitId, int newManufacturerId, decimal pickedPack
                                                               , decimal Convertedpack, int confirmationStatusId, bool changeExpiryDate
                                                               , DateTime?ExpiryDate, bool changeBatchNo, string batchNo)
        {
            //Load the ReceivePallet First From that we Get the Information that We need
            ReceivePallet receivePalletOriginal = new ReceivePallet();

            receivePalletOriginal.LoadByPrimaryKey(receiptPalletId);

            ReceiveDoc receiveDocOriginal = new ReceiveDoc();

            receiveDocOriginal.LoadByPrimaryKey(receivePalletOriginal.ReceiveID);

            //Load ItemUnit Detail for For ItemUnit Change;
            ItemUnit newItemUnit = new ItemUnit();

            newItemUnit.LoadByPrimaryKey(newUnitId);

            // Generate PicklistDetail With OrderDetail information
            PickListService pickListService = new PickListService();
            PickListDetail  pickListDetail  = pickListService.CreatePicklistDetailWithOrder(receiveDocOriginal, receivePalletOriginal, order, picklist,
                                                                                            pickedPack);
            // Generate IssueDoc from picklistDetail and substract the quantity from receiveDoc
            IssueService issueService = new IssueService();

            issueService.CreateIssueFromPicklist(pickListDetail, order, convertedEthDate, stvLog, user);

            if (Convertedpack > 0)
            {
                //duplicate The ReceiveDoc and ReceiptPallet
                ReceiveService receiveService = new ReceiveService();
                receiveService.CloneReceiveForErrorCorrection(confirmationStatusId, receivePalletOriginal, receiveDocOriginal
                                                              , Convertedpack, user, newItemId
                                                              , receiveDocOriginal.StoreID, receiptID
                                                              , newManufacturerId, newItemUnit, convertedEthDate, changeExpiryDate, ExpiryDate, changeBatchNo, batchNo);
            }
        }
        //This is a fix It
        //It will fix the Cost if it is set on the ReceiveDoc but if not set on the picklistdetail
        //But if the receiveDoc is not set or GRV is not printed it will return false

        private static bool ValidateAndFixDeliveryNoteHasBeenProperlyPrice(DataView dv)
        {
            foreach (DataRowView drv in dv)
            {
                int         issueDocId, pickListDetailId;
                CostElement costElement = new CostElement();
                try
                {
                    issueDocId       = Convert.ToInt32(drv["IssueDocID"]);
                    pickListDetailId = Convert.ToInt32(drv["PickListDetailID"]);
                    PickListDetail pickListDetail = costElement.FixDeliveryNoteCostReceiveDoc(issueDocId, pickListDetailId);
                    drv["Cost"]      = pickListDetail.Cost;
                    drv["UnitPrice"] = pickListDetail.UnitPrice;
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(string.Format("You cannot print this STV:{0}", ex.Message), "Warning",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw ex;
                }
            }
            return(true);
        }
Beispiel #13
0
 public IList <PickListResult> GetPickListResult(PickListDetail pickListDetail)
 {
     return(GetPickListResult(pickListDetail.Id));
 }
Beispiel #14
0
        public PickList CreatePickList(IList <OrderLocationTransaction> orderLocationTransactionList, User user)
        {
            List <OrderLocationTransaction>  targetOrderLocationTransactionList = new List <OrderLocationTransaction>();
            OrderLocationTransactionComparer orderLocationTransactionComparer   = new OrderLocationTransactionComparer();

            if (orderLocationTransactionList != null && orderLocationTransactionList.Count > 0)
            {
                foreach (OrderLocationTransaction orderLocationTransaction in orderLocationTransactionList)
                {
                    if (orderLocationTransaction.CurrentShipQty > 0)
                    {
                        targetOrderLocationTransactionList.Add(orderLocationTransaction);
                    }
                }
            }

            if (targetOrderLocationTransactionList.Count == 0)
            {
                throw new BusinessErrorException("Order.Error.PickUp.DetailEmpty");
            }
            else
            {
                //按FromLocation、零件号、单位、单包装排序
                targetOrderLocationTransactionList.Sort(orderLocationTransactionComparer);
            }

            string      orderType          = null;
            Party       partyFrom          = null;
            Party       partyTo            = null;
            ShipAddress shipFrom           = null;
            ShipAddress shipTo             = null;
            string      dockDescription    = null;
            bool?       isShipScanHu       = null;
            bool?       isReceiptScanHu    = null;
            bool?       isAutoReceive      = null;
            decimal?    completeLatency    = null;
            string      grGapTo            = null;
            string      asnTemplate        = null;
            string      receiptTemplate    = null;
            string      flow               = null;
            DateTime?   windowTime         = null;
            bool?       isAsnUniqueReceipt = null;

            #region 判断OrderHead的PartyFrom, PartyTo, ShipFrom, ShipTo, DockDescription是否一致
            foreach (OrderLocationTransaction orderLocationTransaction in targetOrderLocationTransactionList)
            {
                OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
                OrderHead   orderHead   = orderDetail.OrderHead;

                //判断OrderHead的Type是否一致
                if (orderType == null)
                {
                    orderType = orderHead.Type;
                }
                else if (orderHead.Type != orderType)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.OrderTypeNotEqual");
                }

                //判断OrderHead的PartyFrom是否一致
                if (partyFrom == null)
                {
                    partyFrom = orderHead.PartyFrom;
                }
                else if (orderHead.PartyFrom.Code != partyFrom.Code)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.PartyFromNotEqual");
                }

                //判断OrderHead的PartyFrom是否一致
                if (partyTo == null)
                {
                    partyTo = orderHead.PartyTo;
                }
                else if (orderHead.PartyTo.Code != partyTo.Code)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.PartyToNotEqual");
                }

                //判断OrderHead的ShipFrom是否一致
                if (shipFrom == null)
                {
                    shipFrom = orderHead.ShipFrom;
                }
                else if (!AddressHelper.IsAddressEqual(orderHead.ShipFrom, shipFrom))
                {
                    throw new BusinessErrorException("Order.Error.PickUp.ShipFromNotEqual");
                }

                //判断OrderHead的ShipTo是否一致
                if (shipTo == null)
                {
                    shipTo = orderHead.ShipTo;
                }
                else if (!AddressHelper.IsAddressEqual(orderHead.ShipTo, shipTo))
                {
                    throw new BusinessErrorException("Order.Error.PickUp.ShipToNotEqual");
                }

                //判断OrderHead的DockDescription是否一致
                if (dockDescription == null)
                {
                    dockDescription = orderHead.DockDescription;
                }
                else if (orderHead.DockDescription != dockDescription)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.DockDescriptionNotEqual");
                }

                //判断OrderHead的IsShipScanHu是否一致
                if (isShipScanHu == null)
                {
                    isShipScanHu = orderHead.IsShipScanHu;
                }
                else if (orderHead.IsShipScanHu != isShipScanHu)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.IsShipScanHuNotEqual");
                }

                //判断OrderHead的IsReceiptScanHu是否一致
                if (isReceiptScanHu == null)
                {
                    isReceiptScanHu = orderHead.IsReceiptScanHu;
                }
                else if (orderHead.IsReceiptScanHu != isReceiptScanHu)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.IsReceiptScanHuNotEqual");
                }

                //判断OrderHead的IsAutoReceipt是否一致
                if (isAutoReceive == null)
                {
                    isAutoReceive = orderHead.IsAutoReceive;
                }
                else if (orderHead.IsAutoReceive != isAutoReceive)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.IsAutoReceiveNotEqual");
                }

                //判断OrderHead的CompleteLatency是否一致
                if (completeLatency == null)
                {
                    completeLatency = orderHead.CompleteLatency;
                }
                else
                {
                    if (orderHead.CompleteLatency.HasValue && orderHead.CompleteLatency != completeLatency)
                    {
                        throw new BusinessErrorException("Order.Error.PickUp.CompleteLatencyNotEqual");
                    }
                }

                //判断OrderHead的GoodsReceiptGapTo是否一致
                if (grGapTo == null)
                {
                    grGapTo = orderHead.GoodsReceiptGapTo;
                }
                else
                {
                    if (orderHead.GoodsReceiptGapTo != null && orderHead.GoodsReceiptGapTo != grGapTo)
                    {
                        throw new BusinessErrorException("Order.Error.PickUp.GoodsReceiptGapToNotEqual");
                    }
                }

                //判断OrderHead的AsnTemplate是否一致
                if (asnTemplate == null)
                {
                    asnTemplate = orderHead.AsnTemplate;
                }
                else
                {
                    if (orderHead.AsnTemplate != null && orderHead.AsnTemplate != asnTemplate)
                    {
                        throw new BusinessErrorException("Order.Error.PickUp.AsnTemplateNotEqual");
                    }
                }

                //判断OrderHead的ReceiptTemplate是否一致
                if (receiptTemplate == null)
                {
                    receiptTemplate = orderHead.ReceiptTemplate;
                }
                else
                {
                    if (orderHead.ReceiptTemplate != null && orderHead.ReceiptTemplate != receiptTemplate)
                    {
                        throw new BusinessErrorException("Order.Error.PickUp.ReceiptTemplateNotEqual");
                    }
                }

                //判断OrderHead的Flow是否一致
                if (flow == null)
                {
                    flow = orderHead.Flow;
                }
                else if (orderHead.Flow != flow)
                {
                    //throw new BusinessErrorException("Order.Error.PickUp.FlowNotEqual");
                }

                //寻找最小的WindowTime
                if (!windowTime.HasValue)
                {
                    windowTime = orderHead.WindowTime;
                }
                else if (windowTime.Value > orderHead.WindowTime)
                {
                    windowTime = orderHead.WindowTime;
                }

                //判断OrderHead的IsAsnUniqueReceipt是否一致
                if (isAsnUniqueReceipt == null)
                {
                    isAsnUniqueReceipt = orderHead.IsAsnUniqueReceipt;
                }
                else if (orderHead.IsAsnUniqueReceipt != isAsnUniqueReceipt)
                {
                    throw new BusinessErrorException("Order.Error.PickUp.IsAsnUniqueReceiptNotEqual");
                }
            }
            #endregion

            #region 创建捡货单头
            DateTime dateTimeNow = DateTime.Now;

            PickList pickList = new PickList();

            pickList.PickListNo        = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_PICKLIST);
            pickList.Status            = BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT;
            pickList.PickBy            = this.entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_PICK_BY).Value;
            pickList.OrderType         = orderType;
            pickList.PartyFrom         = partyFrom;
            pickList.PartyTo           = partyTo;
            pickList.ShipFrom          = shipFrom;
            pickList.ShipTo            = shipTo;
            pickList.DockDescription   = dockDescription;
            pickList.CreateDate        = dateTimeNow;
            pickList.CreateUser        = user;
            pickList.LastModifyDate    = dateTimeNow;
            pickList.LastModifyUser    = user;
            pickList.IsShipScanHu      = isShipScanHu.Value;
            pickList.IsReceiptScanHu   = isReceiptScanHu.Value;
            pickList.IsAutoReceive     = isAutoReceive.Value;
            pickList.CompleteLatency   = completeLatency;
            pickList.GoodsReceiptGapTo = grGapTo;
            pickList.AsnTemplate       = asnTemplate;
            pickList.ReceiptTemplate   = receiptTemplate;
            pickList.Flow               = flow;
            pickList.WindowTime         = windowTime.Value;
            pickList.IsAsnUniqueReceipt = isAsnUniqueReceipt.Value;

            this.CreatePickList(pickList);
            #endregion

            #region 创建捡货单明细
            int index = 0;
            IList <LocationLotDetail> locationLotDetailList         = null;
            IList <LocationLotDetail> occupiedLocationLotDetailList = null; //捡货占用库存
            for (int i = 0; i < targetOrderLocationTransactionList.Count; i++)
            {
                OrderLocationTransaction orderLocationTransaction     = targetOrderLocationTransactionList[i];                     //本次循环OrderLocationTransaction
                OrderLocationTransaction lastOrderLocationTransaction = i == 0 ? null : targetOrderLocationTransactionList[i - 1]; //上次OrderLocationTransaction
                List <PickListDetail>    pickListDetailList           = new List <PickListDetail>();                               //本次生成的PickListDetail列表

                OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
                OrderHead   orderHead   = orderDetail.OrderHead;
                decimal     shipQty     = orderLocationTransaction.CurrentShipQty; //库存单位

                #region 过量拣货判断
                decimal pickedQty = 0; //其它拣货单的待拣货数量,只考虑Submit和InProcess状态
                IList <PickListDetail> pickedPickListDetailList = this.pickListDetailMgr.GetPickedPickListDetail(orderLocationTransaction.Id);
                if (pickedPickListDetailList != null && pickedPickListDetailList.Count > 0)
                {
                    foreach (PickListDetail pickListDetail in pickedPickListDetailList)
                    {
                        if (pickListDetail.PickList.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT ||
                            pickListDetail.PickList.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS)
                        {
                            pickedQty += pickListDetail.Qty;
                        }
                    }
                }

                //累计发货数量 + 待捡货数量 + 本次拣货数量 不能大于 订单数量
                if ((orderLocationTransaction.AccumulateQty.HasValue ? orderLocationTransaction.AccumulateQty.Value : 0) + shipQty + pickedQty > orderLocationTransaction.OrderedQty)
                {
                    throw new BusinessErrorException("MasterData.PickList.Error.PickExcceed", orderLocationTransaction.Item.Code);
                }
                #endregion

                //比较本次OrderLocationTransaction和上次OrderLocationTransaction,如果不相同需重新查找locationLotDetailList和重置index
                //为了处理订单合并捡货时,相同零件推荐的Hu/LotNo不重复问题
                if (lastOrderLocationTransaction == null ||
                    orderLocationTransactionComparer.Compare(lastOrderLocationTransaction, orderLocationTransaction) == -1)
                {
                    index = 0;

                    #region 零头发货选项查询待拣货列表
                    string oddShipOption = orderDetail.OddShipOption;

                    if (oddShipOption == null || oddShipOption.Trim() == string.Empty)
                    {
                        CodeMaster codeMaster = this.codeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION);

                        oddShipOption = codeMaster.Value;
                    }

                    if (oddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_SHIP_FIRST)
                    {
                        //零头优先发、LotnNo先进先出、货架、包装
                        if (orderHead.IsPickFromBin)
                        {
                            locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, null, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "sb.Sequence;Asc", "Qty;Asc", "Id;Asc" }, orderHead.IsPickFromBin, true, null, null, true);
                        }
                        else
                        {
                            locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, null, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "Qty;Asc", "Id;Asc" }, orderHead.IsPickFromBin, false, null, null, true);
                        }
                        #region 重新排序,把零头放在前面
                        if (locationLotDetailList != null && locationLotDetailList.Count > 0)
                        {
                            IList <LocationLotDetail> oddLocationLotDetailList   = new List <LocationLotDetail>();
                            IList <LocationLotDetail> noOddLocationLotDetailList = new List <LocationLotDetail>();
                            foreach (LocationLotDetail locationLotDetail in locationLotDetailList)
                            {
                                if (!this.locationMgr.IsHuOcuppyByPickList(locationLotDetail.Hu.HuId))
                                {
                                    if (locationLotDetail.Hu.Qty < orderDetail.UnitCount)
                                    {
                                        oddLocationLotDetailList.Add(locationLotDetail);
                                        shipQty += locationLotDetail.Qty;  //零头一定要先发走,不占用待拣货数量
                                    }
                                    else
                                    {
                                        noOddLocationLotDetailList.Add(locationLotDetail);
                                    }
                                }
                            }
                            locationLotDetailList = oddLocationLotDetailList;
                            IListHelper.AddRange <LocationLotDetail>(locationLotDetailList, noOddLocationLotDetailList);
                        }
                        #endregion
                    }
                    else if (oddShipOption == BusinessConstants.CODE_MASTER_ODD_SHIP_OPTION_VALUE_NOT_SHIP)
                    {
                        //零头不发
                        if (orderHead.IsPickFromBin)
                        {
                            locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "sb.Sequence;Asc", "Id;Asc" }, orderHead.IsPickFromBin, true);
                        }
                        else
                        {
                            locationLotDetailList = this.locationLotDetailMgr.GetHuLocationLotDetail(orderLocationTransaction.Location.Code, null, null, null, orderDetail.Item.Code, null, false, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { "hu.ManufactureDate;Asc", "Id;Asc" }, orderHead.IsPickFromBin, false);
                        }
                    }

                    #endregion

                    IList <PickListDetail> submitPickListDetailList = this.pickListDetailMgr.GetPickListDetail(orderLocationTransaction.Location.Code, orderDetail.Item.Code, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT, BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS });
                    //IList<PickListResult> inprocessPickListResultList = this.pickListResultMgr.GetPickListResult(orderLocationTransaction.Location.Code, orderDetail.Item.Code, orderDetail.UnitCount, orderDetail.Uom.Code, new string[] { BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS });

                    occupiedLocationLotDetailList = this.Convert2OccupiedLocationLotDetail(submitPickListDetailList, pickList.PickBy);
                }

                if (locationLotDetailList != null && locationLotDetailList.Count > 0)
                {
                    PickListDetail lastestPickListDetail = null;
                    for (; index < locationLotDetailList.Count; index++)
                    {
                        LocationLotDetail locationLotDetail = locationLotDetailList[index];
                        decimal           locQty            = locationLotDetail.Qty;

                        if (pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_HU)
                        {
                            #region  Hu捡货

                            #region 过滤掉已经被推荐的库存
                            if (occupiedLocationLotDetailList != null && occupiedLocationLotDetailList.Count > 0)
                            {
                                bool findMatch = false;
                                foreach (LocationLotDetail occupiedLocationLotDetail in occupiedLocationLotDetailList)
                                {
                                    if (occupiedLocationLotDetail.Hu.HuId == locationLotDetail.Hu.HuId)
                                    {
                                        findMatch = true;
                                        continue;
                                    }
                                }

                                if (findMatch)
                                {
                                    continue;
                                }
                            }
                            #endregion

                            shipQty -= locQty;

                            PickListDetail pickListDetail = new PickListDetail();

                            pickListDetail.PickList = pickList;
                            pickListDetail.OrderLocationTransaction = orderLocationTransaction;
                            pickListDetail.Item      = orderLocationTransaction.Item;
                            pickListDetail.UnitCount = orderDetail.UnitCount;
                            pickListDetail.Uom       = orderDetail.Uom;
                            pickListDetail.HuId      = locationLotDetail.Hu.HuId;
                            pickListDetail.LotNo     = locationLotDetail.LotNo;
                            pickListDetail.Location  = locationLotDetail.Location;
                            if (locationLotDetail.StorageBin != null)
                            {
                                pickListDetail.StorageArea = locationLotDetail.StorageBin.Area;
                                pickListDetail.StorageBin  = locationLotDetail.StorageBin;
                            }
                            pickListDetail.Qty = locQty / orderLocationTransaction.UnitQty; //订单单位
                            this.pickListDetailMgr.CreatePickListDetail(pickListDetail);
                            pickList.AddPickListDetail(pickListDetail);
                            pickListDetailList.Add(pickListDetail);

                            if (shipQty <= 0)
                            {
                                index++;
                                break;
                            }
                            #endregion
                        }
                        else if (pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO)
                        {
                            #region  LotNo捡货

                            #region 过滤掉已经被推荐的库存
                            if (occupiedLocationLotDetailList != null && occupiedLocationLotDetailList.Count > 0)
                            {
                                foreach (LocationLotDetail occupiedLocationLotDetail in occupiedLocationLotDetailList)
                                {
                                    if (occupiedLocationLotDetail.Item.Code == locationLotDetail.Item.Code &&
                                        occupiedLocationLotDetail.LotNo == locationLotDetail.LotNo &&
                                        occupiedLocationLotDetail.Location.Code == locationLotDetail.Location.Code &&
                                        StorageBinHelper.IsStorageBinEqual(occupiedLocationLotDetail.StorageBin, locationLotDetail.StorageBin))
                                    {
                                        if (locationLotDetail.Hu.Qty < orderDetail.UnitCount)
                                        {
                                            shipQty -= locationLotDetail.Qty;  //如果零头被占用,需要扣减发货数量
                                        }

                                        if (occupiedLocationLotDetail.Qty == 0)
                                        {
                                            continue;
                                        }

                                        if (occupiedLocationLotDetail.Qty - locQty >= 0)
                                        {
                                            occupiedLocationLotDetail.Qty -= locQty;
                                            locQty = 0;
                                            continue;
                                        }
                                        else
                                        {
                                            occupiedLocationLotDetail.Qty = 0;
                                            locQty -= occupiedLocationLotDetail.Qty;
                                            break;
                                        }
                                    }
                                }

                                if (locQty == 0)
                                {
                                    continue;
                                }
                            }
                            #endregion

                            shipQty -= locQty;

                            if (shipQty < 0)
                            {
                                locQty += shipQty;
                                shipQty = 0;
                            }

                            if (lastestPickListDetail != null &&
                                lastestPickListDetail.LotNo == locationLotDetail.LotNo &&
                                StorageBinHelper.IsStorageBinEqual(lastestPickListDetail.StorageBin, locationLotDetail.StorageBin))
                            {
                                #region 合并捡货数量
                                lastestPickListDetail.Qty += locQty / orderLocationTransaction.UnitQty; //订单单位
                                this.pickListDetailMgr.UpdatePickListDetail(lastestPickListDetail);
                                #endregion
                            }
                            else
                            {
                                #region 新增捡货明细
                                lastestPickListDetail = new PickListDetail();

                                lastestPickListDetail.PickList = pickList;
                                lastestPickListDetail.OrderLocationTransaction = orderLocationTransaction;
                                lastestPickListDetail.Item      = orderLocationTransaction.Item;
                                lastestPickListDetail.UnitCount = locationLotDetail.Hu.UnitCount;  //可能拣货的包装和订单明细包装不一致,所以使用Hu上的单包装
                                lastestPickListDetail.Uom       = orderDetail.Uom;
                                lastestPickListDetail.LotNo     = locationLotDetail.Hu.LotNo;
                                lastestPickListDetail.Location  = locationLotDetail.Location;
                                if (locationLotDetail.StorageBin != null)
                                {
                                    lastestPickListDetail.StorageArea = locationLotDetail.StorageBin.Area;
                                    lastestPickListDetail.StorageBin  = locationLotDetail.StorageBin;
                                }
                                lastestPickListDetail.Qty = locQty / orderLocationTransaction.UnitQty; //订单单位

                                this.pickListDetailMgr.CreatePickListDetail(lastestPickListDetail);
                                pickList.AddPickListDetail(lastestPickListDetail);
                                pickListDetailList.Add(lastestPickListDetail);
                                #endregion
                            }

                            if (shipQty <= 0)
                            {
                                index++;
                                break;
                            }
                            #endregion
                        }
                        else
                        {
                            throw new TechnicalException("Invalied PickBy value:" + pickList.PickBy);
                        }
                    }
                }

                //if (pickListDetailList.Count == 0)
                //{
                //    throw new BusinessErrorException("MasterData.PickList.Error.NotEnoughInventory");
                //}

                if (shipQty > 0)
                {
                    PickListDetail pickListDetail = new PickListDetail();

                    pickListDetail.PickList = pickList;
                    pickListDetail.OrderLocationTransaction = orderLocationTransaction;
                    pickListDetail.Item      = orderLocationTransaction.Item;
                    pickListDetail.UnitCount = orderDetail.UnitCount;
                    pickListDetail.Uom       = orderDetail.Uom;
                    pickListDetail.Location  = orderLocationTransaction.Location;
                    pickListDetail.Qty       = shipQty / orderLocationTransaction.UnitQty;                                        //订单单位
                    pickListDetail.Memo      = this.languageMgr.TranslateMessage("MasterData.PickList.NotEnoughInventory", user); //设置Memo为库存不足

                    pickList.AddPickListDetail(pickListDetail);

                    this.pickListDetailMgr.CreatePickListDetail(pickListDetail);
                }

                if (pickListDetailList.Count > 0 && pickList.PickBy == BusinessConstants.CODE_MASTER_PICKBY_LOTNO)
                {
                    string lotNo         = string.Empty;
                    bool   hasMultiLotNo = false;
                    foreach (PickListDetail pickListDetail in pickListDetailList)
                    {
                        if (lotNo == string.Empty)
                        {
                            lotNo = pickListDetail.LotNo;
                        }
                        else if (lotNo != pickListDetail.LotNo)
                        {
                            hasMultiLotNo = true;
                            break;
                        }
                    }

                    //设置Memo为多批号
                    if (hasMultiLotNo)
                    {
                        foreach (PickListDetail pickListDetail in pickListDetailList)
                        {
                            if (pickListDetail.Memo == null || pickListDetail.Memo.Trim() == string.Empty)
                            {
                                pickListDetail.Memo = this.languageMgr.TranslateMessage("MasterData.PickList.MultiLotNo", user);
                            }
                            else
                            {
                                pickListDetail.Memo += "; " + this.languageMgr.TranslateMessage("MasterData.PickList.MultiLotNo", user);
                            }
                            this.pickListDetailMgr.UpdatePickListDetail(pickListDetail);
                        }
                    }
                }
            }
            #endregion

            //if (pickList.PickListDetails == null || pickList.PickListDetails.Count == 0)
            //{
            //    throw new BusinessErrorException("MasterData.PickList.Error.NotEnoughInventory");
            //}

            return(pickList);
        }
Beispiel #15
0
        private void tpDelete_Click(object sender, EventArgs e)
        {
            DataRow dr = gridViewBinCard.GetFocusedDataRow();

            if (Convert.ToInt32(dr["Precedance"]) != 3)
            {
                XtraMessageBox.Show("You cannot delete this");
                return;
            }
            if (CurrentContext.LoggedInUser.UserType == UserType.Constants.DISTRIBUTION_MANAGER_WITH_DELETE)
            {
                if (
                    XtraMessageBox.Show(
                        "Are you sure you want to delete this transaction? You will not be able to undo this.",
                        "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    MyGeneration.dOOdads.TransactionMgr tranMgr =
                        MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

                    try
                    {
                        tranMgr.BeginTransaction();

                        ReceiveDoc    rdoc = new ReceiveDoc();
                        ReceivePallet rp   = new ReceivePallet();
                        IssueDoc      idoc = new IssueDoc();

                        PickListDetail pld     = new PickListDetail();
                        int            issueID = Convert.ToInt32(dr["ID"]);
                        //pld.LoadByOrderAndItem(Convert.ToInt32(dr["OrderID"]), Convert.ToInt32(dr["ItemID"]),
                        //                       Convert.ToInt32(dr["Quantity"]));
                        idoc.LoadByPrimaryKey(issueID);
                        pld.LoadByPrimaryKey(idoc.PLDetailID);

                        string RefNo = idoc.RefNo;

                        rdoc.LoadByPrimaryKey(idoc.RecievDocID);


                        //if (pld.RowCount == 0)
                        //{
                        //    pld.LoadByOrderAndItem(Convert.ToInt32(dr["OrderID"]), Convert.ToInt32(dr["ItemID"]));
                        //}

                        rp.LoadByPrimaryKey(pld.ReceivePalletID);
                        PalletLocation pl = new PalletLocation();
                        pl.loadByPalletID(rp.PalletID);

                        if (pl.RowCount == 0)
                        {
                            pl.LoadByPrimaryKey(pld.PalletLocationID);
                            if (pl.IsColumnNull("PalletID"))
                            {
                                pl.PalletID = rp.PalletID;
                                pl.Save();
                            }
                            //rp.LoadNonZeroRPByReceiveID(rdoc.ID);
                        }


                        if (rp.RowCount == 0)
                        {
                            XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error");
                            return;
                        }
                        if (rp.RowCount > 0)
                        {
                            rdoc.QuantityLeft += idoc.Quantity;
                            rp.Balance        += idoc.Quantity;
                            pld.QuantityInBU   = 0;


                            // are we adding it the pick face?
                            // if so add it to the balance of the pick face also
                            pl.loadByPalletID(rp.PalletID);

                            if (pl.RowCount == 0)
                            {
                                PutawayLocation plocation = new PutawayLocation(rdoc.ItemID);

                                // we don't have a location for this yet,
                                // select a new location
                                //PutawayLocataion pl = new PutawayLocataion();
                                if (plocation.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    pl.LoadByPrimaryKey(plocation.PalletLocationID);
                                    if (pl.RowCount > 0)
                                    {
                                        pl.PalletID = rp.PalletID;
                                        pl.Save();
                                    }
                                }
                            }

                            if (pl.RowCount > 0)
                            {
                                PickFace pf = new PickFace();
                                pf.LoadByPalletLocation(pl.ID);
                                if (pf.RowCount > 0)
                                {
                                    pf.Balance += Convert.ToInt32(idoc.Quantity);
                                    pf.Save();
                                }


                                IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId);
                                idoc.MarkAsDeleted();
                                rdoc.Save();
                                rp.Save();
                                idoc.Save();


                                // now refresh the window
                                XtraMessageBox.Show("Issue Deleted!", "Confirmation", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                tranMgr.CommitTransaction();
                                //TODO: refresh the list
                                // gridViewReferences_FocusedRowChanged(null, null);
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show(
                                "This delete is not successfull because a free pick face location was not selected. please select a free location and try again.",
                                "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            tranMgr.RollbackTransaction();
                        }
                    }
                    catch
                    {
                        XtraMessageBox.Show("This delete is not successfull", "Warning ...", MessageBoxButtons.OK,
                                            MessageBoxIcon.Warning);
                        tranMgr.RollbackTransaction();
                    }
                }
            }
            else
            {
                XtraMessageBox.Show(
                    "You cannot delete this transaction because you don't have previlage. Please contact the administrator if you thing this is an error.",
                    "Delete is not allowed");
            }
        }
Beispiel #16
0
 public virtual void UpdatePickListDetail(PickListDetail entity)
 {
     entityDao.UpdatePickListDetail(entity);
 }
Beispiel #17
0
 public virtual void DeletePickListDetail(PickListDetail entity)
 {
     Delete(entity);
 }
Beispiel #18
0
 public virtual void UpdatePickListDetail(PickListDetail entity)
 {
     Update(entity);
 }
Beispiel #19
0
 public virtual void CreatePickListDetail(PickListDetail entity)
 {
     Create(entity);
 }
        private void SaveOrder()
        {
            var order    = GenerateOrder();
            var picklist = PickList.GeneratePickList(order.ID);

            int lineNo = 0;

            // This is a kind of initializing the data table.
            OrderDetail    ord      = new OrderDetail();
            PickListDetail pkDetail = new PickListDetail();
            DataView       dv       = orderGrid.DataSource as DataView;

            foreach (DataRowView r in dv)
            {
                if (r["ApprovedPacks"] != null && r["ApprovedPacks"] != DBNull.Value && r["ApprovedPacks"].ToString() != "")
                {
                    if (Convert.ToInt32(r["ApprovedPacks"]) != 0)
                    {
                        lineNo = lineNo + 1;
                        int itemID = Convert.ToInt32(r["ItemID"]);
                        int unitID = Convert.ToInt32(r["UnitID"]);
                        ord.AddNew();
                        ord.OrderID = order.ID;
                        ord.ItemID  = itemID;
                        if (r["ApprovedPacks"] != DBNull.Value)
                        {
                            ord.Pack = Convert.ToInt32(r["ApprovedPacks"]);
                        }
                        if (r["QtyPerPack"] != DBNull.Value)
                        {
                            ord.QtyPerPack = Convert.ToInt32(r["QtyPerPack"]);
                        }
                        ord.Quantity         = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]);
                        ord.ApprovedQuantity = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]);
                        ord.UnitID           = unitID;
                        ord.StoreID          = Convert.ToInt32(lkAccountType.EditValue);


                        ord.Save();
                        pkDetail.AddNew();
                        pkDetail.PickListID       = picklist.ID;
                        pkDetail.ItemID           = itemID;
                        pkDetail.PalletLocationID = Convert.ToInt32(r["LocationID"]);
                        pkDetail.BatchNumber      = r["BatchNo"].ToString();
                        if (r["ExpDate"] != DBNull.Value)
                        {
                            pkDetail.ExpireDate = DateTime.Parse(r["ExpDate"].ToString());
                        }

                        pkDetail.StoreID      = Convert.ToInt32(r["StoreID"]);
                        pkDetail.UnitID       = unitID;
                        pkDetail.ReceiveDocID = Convert.ToInt32(r["ReceiveDocID"]);
                        if (r["UnitPrice"] != DBNull.Value)
                        {
                            pkDetail.Cost      = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToDouble(r["UnitPrice"]);
                            pkDetail.UnitPrice = Convert.ToDouble(r["UnitPrice"]);
                        }
                        pkDetail.Packs           = Convert.ToInt32(r["ApprovedPacks"]);
                        pkDetail.QtyPerPack      = Convert.ToInt32(r["QtyPerPack"]);
                        pkDetail.QuantityInBU    = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]);
                        pkDetail.StoreID         = Convert.ToInt32(r["StoreID"]);
                        pkDetail.ReceivePalletID = Convert.ToInt32(r["ReceivingLocationID"]);
                        pkDetail.ManufacturerID  = Convert.ToInt32(r["ManufacturerID"]);
                        pkDetail.BoxLevel        = 0;
                        pkDetail.DeliveryNote    = true;
                        pkDetail.Save();
                        //To Print The Picklist
                        //Then reserve Items
                        ReceivePallet receivepallet = new ReceivePallet();
                        receivepallet.LoadByPrimaryKey(Convert.ToInt32(r["ReceivingLocationID"]));
                        receivepallet.ReservedStock = receivepallet.ReservedStock + Convert.ToInt32(r["ApprovedPacks"]);
                        receivepallet.Save();


                        DataRow drvpl = dvPickList.NewRow();
                        drvpl["FullItemName"] = r["FullItemName"];
                        drvpl["StockCode"]    = r["StockCode"];
                        drvpl["BatchNo"]      = r["BatchNo"];
                        if (r["ExpDate"] != DBNull.Value)
                        {
                            drvpl["ExpDate"] = Convert.ToDateTime(r["ExpDate"]).ToString("MMM/yyyy");
                        }
                        else
                        {
                            drvpl["ExpDate"] = DBNull.Value;
                        }
                        drvpl["LineNum"]          = lineNo + 1;
                        drvpl["ManufacturerName"] = r["Manufacturer"];
                        drvpl["Pack"]             = r["ApprovedPacks"];
                        drvpl["UnitPrice"]        = r["UnitPrice"];

                        drvpl["Unit"]           = r["Unit"];
                        drvpl["PalletLocation"] = r["Location"];
                        drvpl["QtyInSKU"]       = Convert.ToInt32(r["ApprovedPacks"]);
                        if (r["UnitPrice"] != DBNull.Value)
                        {
                            drvpl["CalculatedCost"] = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToDouble(r["UnitPrice"]);
                        }

                        PalletLocation palletLocation = new PalletLocation();
                        palletLocation.LoadByPrimaryKey(pkDetail.PalletLocationID);
                        drvpl["WarehouseName"]     = palletLocation.WarehouseName;
                        drvpl["PhysicalStoreName"] = palletLocation.PhysicalStoreName;
                        var activity = new Activity();
                        activity.LoadByPrimaryKey(pkDetail.StoreID);
                        drvpl["ActivityConcat"] = activity.FullActivityName;
                        drvpl["AccountName"]    = activity.AccountName;
                        dvPickList.Rows.Add(drvpl);
                    }
                }
            }
            if (lineNo == 0)
            {
                throw new System.ArgumentException("Please review your list,you haven't approved any Quantity");
            }

            var plr = HCMIS.Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(order, lkForHub.Text,
                                                                                       dvPickList.DefaultView);


            plr.PrintDialog();

            if (!BLL.Settings.IsCenter)
            {
                if (TransferTypeID == 3)
                {
                    XtraMessageBox.Show("Your Store To Store Transfer will be Printed now", "Store To Store Transfer");
                    Transfer.Move(picklist.ID);
                    HCMIS.Desktop.Reports.StoreTransferPrintOut STM =
                        new HCMIS.Desktop.Reports.StoreTransferPrintOut();
                    STM.LoadByPickListID(picklist.ID);
                    STM.PrintDialog();
                }
                else if (TransferTypeID == 2)
                {
                    XtraMessageBox.Show(ReceiveDoc.ReceiveFromAccountTransfer(picklist.ID,
                                                                              Convert.ToInt32(lkForHub.EditValue),
                                                                              CurrentContext.LoggedInUserName,
                                                                              CurrentContext.UserId));
                }
            }
            else
            {
                XtraMessageBox.Show("Picklist Prepared!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private int SaveOrder()
        {
            int      warehouseID;
            var      order      = GenerateOrder();
            PickList pickList   = PickList.GeneratePickList(order.ID);
            int      picklistId = pickList.ID;

            if (TransferTypeID != Transfer.Constants.HUB_TO_HUB)
            {
                warehouseID = GenerateTransfer(order.ID);
            }

            // Log
            this.LogActivity("Transfer", order.ID);


            int LineNo = 0;

            // This is a kind of initializing the data table.


            DataView dv = orderGrid.DataSource as DataView;

            foreach (DataRowView r in dv)
            {
                if (r["ApprovedPacks"] != null && r["ApprovedPacks"] != DBNull.Value && r["ApprovedPacks"].ToString() != "")
                {
                    if (Convert.ToDecimal(r["ApprovedPacks"]) != 0)
                    {
                        LineNo = LineNo + 1;
                        int     itemId           = Convert.ToInt32(r["ItemID"]);
                        int     unitId           = Convert.ToInt32(r["UnitID"]);
                        decimal pack             = Convert.ToDecimal(r["ApprovedPacks"]);
                        int     qtyPerPack       = Convert.ToInt32(r["QtyPerPack"]);
                        int     activityId       = Convert.ToInt32(lkFromActivity.EditValue);
                        int     manufacturerId   = Convert.ToInt32(Convert.ToInt32(r["ManufacturerID"]));
                        int     receivePalletId  = Convert.ToInt32(r["ReceivingLocationID"]);
                        int     palletLocationId = Convert.ToInt32(r["LocationID"]);
                        double? unitPrice;
                        string  batchNumber  = r["BatchNo"].ToString();
                        string  expireDate   = "";
                        int     receiveDocId = Convert.ToInt32(r["ReceiveDocID"]);
                        if ((r["UnitPrice"] != DBNull.Value))
                        {
                            unitPrice = Convert.ToDouble(r["UnitPrice"]);
                        }
                        else
                        {
                            unitPrice = null;
                        }

                        if (r["ExpDate"] != DBNull.Value)
                        {
                            expireDate = r["ExpDate"].ToString();
                        }

                        OrderDetail    ord            = OrderDetail.GenerateOrderDetail(unitId, activityId, pack, order.ID, qtyPerPack, itemId);
                        PalletLocation palletLocation = new PalletLocation();
                        palletLocation.LoadByPrimaryKey(palletLocationId);
                        int            palletID = palletLocation.PalletID;
                        PickListDetail pkDetail = PickListDetail.GeneratePickListDetail(pack, unitPrice, receiveDocId, manufacturerId, receivePalletId, qtyPerPack, activityId, unitId, itemId, picklistId, palletID, expireDate, batchNumber);
                        ReceivePallet.ReserveQty(pack, receivePalletId);
                        //To Print The Picklist
                        //Then reserve Items


                        Item item = new Item();
                        item.LoadByPrimaryKey(itemId);
                        DataRow drvpl = dvPickList.NewRow();
                        drvpl["FullItemName"] = item.FullItemName;
                        drvpl["StockCode"]    = item.StockCode;
                        drvpl["BatchNo"]      = batchNumber;
                        if (expireDate != "")
                        {
                            drvpl["ExpDate"] = Convert.ToDateTime(expireDate).ToString("MMM/yyyy");
                        }
                        else
                        {
                            drvpl["ExpDate"] = DBNull.Value;
                        }
                        drvpl["LineNum"] = LineNo + 1;
                        var manufacturer = new Manufacturer();
                        manufacturer.LoadByPrimaryKey(manufacturerId);
                        drvpl["ManufacturerName"] = manufacturer.Name;

                        drvpl["Pack"]      = pack;
                        drvpl["UnitPrice"] = unitPrice;
                        var unit = new ItemUnit();
                        unit.LoadByPrimaryKey(unitId);

                        drvpl["Unit"] = unit.Text;

                        drvpl["QtyInSKU"] = pack;
                        if (unitPrice != null)
                        {
                            drvpl["CalculatedCost"] = pack * Convert.ToDecimal(unitPrice);
                        }


                        palletLocation.LoadByPrimaryKey(pkDetail.PalletLocationID);
                        drvpl["PalletLocation"]    = palletLocation.Label;
                        drvpl["WarehouseName"]     = palletLocation.WarehouseName;
                        drvpl["PhysicalStoreName"] = palletLocation.PhysicalStoreName;
                        var activity = new Activity();
                        activity.LoadByPrimaryKey(pkDetail.StoreID);
                        drvpl["ActivityConcat"] = activity.FullActivityName;
                        drvpl["AccountName"]    = activity.AccountName;
                        dvPickList.Rows.Add(drvpl);
                    }
                }
            }
            if (LineNo == 0)
            {
                throw new System.ArgumentException("Please review your list,you haven't approved any Quantity");
            }
            string   receivingUnit;
            Transfer transfer = new Transfer();

            transfer.LoadByOrderID(order.ID);
            if (TransferTypeID == Transfer.Constants.ACCOUNT_TO_ACCOUNT)
            {
                var fromActivity = new Activity();
                fromActivity.LoadByPrimaryKey(transfer.FromStoreID);
                var toActivity = new Activity();
                toActivity.LoadByPrimaryKey(transfer.ToStoreID);

                receivingUnit = String.Format("Account to Account from {0} to {1}", fromActivity.FullActivityName,
                                              toActivity.FullActivityName);
            }
            else if (TransferTypeID == Transfer.Constants.STORE_TO_STORE)
            {
                var toStore = new PhysicalStore();

                toStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID);
                receivingUnit = string.Format("Store to Store transfer to: {0}", toStore.WarehouseName);
            }
            else
            {
                receivingUnit = lkForHub.Text;
            }
            var plr = HCMIS.Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(order, receivingUnit,
                                                                                       dvPickList.DefaultView);

            plr.PrintDialog();

            XtraMessageBox.Show("Picklist Prepared!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return(order.ID);
        }
Beispiel #22
0
 public virtual void CreatePickListDetail(PickListDetail entity)
 {
     entityDao.CreatePickListDetail(entity);
 }
        public IssueDoc CreateIssueFromPicklist(PickListDetail picklistDetail,Order order,DateTime convertedEthDate,Issue stvLog,User user)
        {
            ReceivePallet receivePallet = new ReceivePallet();
            receivePallet.LoadByPrimaryKey(picklistDetail.ReceivePalletID);

            ReceiveDoc receiveDoc = new ReceiveDoc();
            receiveDoc.LoadByPrimaryKey(receivePallet.ReceiveID);

            IssueDoc issueDoc = new IssueDoc();
            issueDoc.AddNew();
            issueDoc.BatchNo = picklistDetail.BatchNumber;
            if(!picklistDetail.IsColumnNull("Cost"))
            issueDoc.Cost = picklistDetail.Cost;
            issueDoc.Date = convertedEthDate;
            issueDoc.EurDate = DateTimeHelper.ServerDateTime;
            issueDoc.StoreId = picklistDetail.StoreID;
            issueDoc.STVID = stvLog.ID;
            issueDoc.IsTransfer = true;
            issueDoc.IssuedBy = user.FullName;
            issueDoc.ItemID = picklistDetail.ItemID;
            issueDoc.NoOfPack = picklistDetail.Packs;
            issueDoc.QtyPerPack = picklistDetail.QtyPerPack;
            issueDoc.Quantity = picklistDetail.QuantityInBU;
            issueDoc.OrderID = order.ID;
            issueDoc.UnitID = receiveDoc.UnitID;
            issueDoc.ManufacturerID = receiveDoc.ManufacturerId;
            issueDoc.SetColumn("UnitCost" ,receiveDoc.GetColumn("Cost"));
            issueDoc.SetColumn("SellingPrice"  ,receiveDoc.GetColumn("SellingPrice"));
            issueDoc.SetColumn("Margin", receiveDoc.GetColumn("Margin"));
            issueDoc.SetColumn("PhysicalStoreID", receiveDoc.GetColumn("PhysicalStoreID"));
            issueDoc.PLDetailID = picklistDetail.ID;
            issueDoc.RecievDocID = picklistDetail.ReceiveDocID;
            issueDoc.SetColumn("InventoryPeriodID", receiveDoc.GetColumn("InventoryPeriodID"));
            // This is a deprecated field
            issueDoc.RecomendedQty = 0;// picklistDetail.Packs;
            issueDoc.RefNo = stvLog.IDPrinted.ToString();
            issueDoc.DispatchConfirmed = false;
            issueDoc.Save();

            //substract from QuantityLeft
            receiveDoc.QuantityLeft -= picklistDetail.QuantityInBU;
            if(receiveDoc.QuantityLeft < 0)
            {
                receiveDoc.QuantityLeft = 0;
            }
            receiveDoc.Save();

            receivePallet.Balance -= picklistDetail.QuantityInBU;
            if(receivePallet.Balance < 0)
            {
                receivePallet.Balance=0;
            }

            receivePallet.ReservedStock -= picklistDetail.Packs;
            if(receivePallet.ReservedStock < 0)
            {
                receivePallet.ReservedStock = 0;
            }
            receivePallet.Save();

            return issueDoc;
        }
Beispiel #24
0
 public virtual void DeletePickListDetail(PickListDetail entity)
 {
     entityDao.DeletePickListDetail(entity);
 }
        public static void DeleteIssueDoc(int issueID)
        {
            MyGeneration.dOOdads.TransactionMgr tranMgr =
                MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            try
            {
                tranMgr.BeginTransaction();


                var pld  = new PickListDetail();
                var rdoc = new ReceiveDoc();
                var rp   = new ReceivePallet();
                var idoc = new IssueDoc();

                idoc.LoadByPrimaryKey(issueID);
                pld.LoadByPrimaryKey(idoc.PLDetailID);
                rdoc.LoadByPrimaryKey(idoc.RecievDocID);

                rp.LoadByPrimaryKey(pld.ReceivePalletID);
                var pl = new PalletLocation();
                pl.loadByPalletID(rp.PalletID);

                if (pl.RowCount == 0)
                {
                    pl.LoadByPrimaryKey(pld.PalletLocationID);
                    if (pl.IsColumnNull("PalletID"))
                    {
                        pl.PalletID = rp.PalletID;
                        pl.Save();
                    }
                }


                if (rp.RowCount == 0)
                {
                    XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error");
                    return;
                }
                if (rp.RowCount > 0)
                {
                    // in error cases this could lead to a number greater than the received quantity
                    // instead of being an error, it should just delete the respective issue and
                    // adjust the remaining quantity to the received quantity.
                    if (rdoc.QuantityLeft + idoc.Quantity > rdoc.Quantity)
                    {
                        rdoc.QuantityLeft = rp.Balance = rdoc.Quantity;
                    }
                    else
                    {
                        rdoc.QuantityLeft += idoc.Quantity;
                        rp.Balance        += idoc.Quantity;
                    }

                    //Delete from picklistDetail and add to pickListDetailDeleted
                    PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId);
                    pld.MarkAsDeleted();

                    // are we adding it the pick face?
                    // if so add it to the balance of the pick face also
                    pl.loadByPalletID(rp.PalletID);

                    if (pl.RowCount == 0)
                    {
                        var plocation = new PutawayLocation(rdoc.ItemID);

                        // we don't have a location for this yet,
                        // select a new location
                        //PutawayLocataion pl = new PutawayLocataion();
                        if (plocation.ShowDialog() == DialogResult.OK)
                        {
                            pl.LoadByPrimaryKey(plocation.PalletLocationID);
                            if (pl.RowCount > 0)
                            {
                                pl.PalletID = rp.PalletID;
                                pl.Save();
                            }
                        }
                    }

                    if (pl.RowCount > 0)
                    {
                        var pf = new PickFace();
                        pf.LoadByPalletLocation(pl.ID);
                        if (pf.RowCount > 0)
                        {
                            pf.Balance += Convert.ToInt32(idoc.Quantity);
                            pf.Save();
                        }


                        IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId);
                        idoc.MarkAsDeleted();
                        rdoc.Save();
                        rp.Save();
                        idoc.Save();
                        pld.Save();


                        // now refresh the window
                        XtraMessageBox.Show("Issue Deleted!", "Confirmation", MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        tranMgr.CommitTransaction();
                    }
                }
                else
                {
                    XtraMessageBox.Show(
                        "This delete is not successfull because a free pick face location was not selected. please select a free location and try again.",
                        "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tranMgr.RollbackTransaction();
                }
            }
            catch
            {
                XtraMessageBox.Show("This delete is not successfull", "Warning ...", MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                tranMgr.RollbackTransaction();
            }
        }
        public IssueDoc CreateIssueFromPicklist(PickListDetail picklistDetail, Order order, DateTime convertedEthDate, Issue stvLog, User user)
        {
            ReceivePallet receivePallet = new ReceivePallet();

            receivePallet.LoadByPrimaryKey(picklistDetail.ReceivePalletID);

            ReceiveDoc receiveDoc = new ReceiveDoc();

            receiveDoc.LoadByPrimaryKey(receivePallet.ReceiveID);

            IssueDoc issueDoc = new IssueDoc();

            issueDoc.AddNew();
            issueDoc.BatchNo = picklistDetail.BatchNumber;
            if (!picklistDetail.IsColumnNull("Cost"))
            {
                issueDoc.Cost = picklistDetail.Cost;
            }
            issueDoc.Date           = convertedEthDate;
            issueDoc.EurDate        = DateTimeHelper.ServerDateTime;
            issueDoc.StoreId        = picklistDetail.StoreID;
            issueDoc.STVID          = stvLog.ID;
            issueDoc.IsTransfer     = true;
            issueDoc.IssuedBy       = user.FullName;
            issueDoc.ItemID         = picklistDetail.ItemID;
            issueDoc.NoOfPack       = picklistDetail.Packs;
            issueDoc.QtyPerPack     = picklistDetail.QtyPerPack;
            issueDoc.Quantity       = picklistDetail.QuantityInBU;
            issueDoc.OrderID        = order.ID;
            issueDoc.UnitID         = receiveDoc.UnitID;
            issueDoc.ManufacturerID = receiveDoc.ManufacturerId;
            issueDoc.SetColumn("UnitCost", receiveDoc.GetColumn("Cost"));
            issueDoc.SetColumn("SellingPrice", receiveDoc.GetColumn("SellingPrice"));
            issueDoc.SetColumn("Margin", receiveDoc.GetColumn("Margin"));
            issueDoc.SetColumn("PhysicalStoreID", receiveDoc.GetColumn("PhysicalStoreID"));
            issueDoc.PLDetailID  = picklistDetail.ID;
            issueDoc.RecievDocID = picklistDetail.ReceiveDocID;
            issueDoc.SetColumn("InventoryPeriodID", receiveDoc.GetColumn("InventoryPeriodID"));
            // This is a deprecated field
            issueDoc.RecomendedQty     = 0;// picklistDetail.Packs;
            issueDoc.RefNo             = stvLog.IDPrinted.ToString();
            issueDoc.DispatchConfirmed = false;
            issueDoc.Save();



            //substract from QuantityLeft
            receiveDoc.QuantityLeft -= picklistDetail.QuantityInBU;
            if (receiveDoc.QuantityLeft < 0)
            {
                receiveDoc.QuantityLeft = 0;
            }
            receiveDoc.Save();

            receivePallet.Balance -= picklistDetail.QuantityInBU;
            if (receivePallet.Balance < 0)
            {
                receivePallet.Balance = 0;
            }

            receivePallet.ReservedStock -= picklistDetail.Packs;
            if (receivePallet.ReservedStock < 0)
            {
                receivePallet.ReservedStock = 0;
            }
            receivePallet.Save();

            return(issueDoc);
        }
Beispiel #27
0
        public void DeleteAnIssue(int issueDociD)
        {
            ReceiveDoc    rdoc = new ReceiveDoc();
            ReceivePallet rp   = new ReceivePallet();
            IssueDoc      idoc = new IssueDoc();

            idoc.LoadByPrimaryKey(issueDociD);

            if (idoc.IsThereSRM)
            {
                throw new Exception("There is an SRM for this issue.  You can't void it.");
            }

            PickListDetail pld = new PickListDetail();

            //pld.LoadByOrderAndItem(idoc.OrderID, idoc.ItemID, idoc.NoOfPack);
            pld.LoadByPrimaryKey(idoc.PLDetailID);

            string RefNo = idoc.RefNo;

            rdoc.LoadByPrimaryKey(idoc.RecievDocID);

            //if (pld.RowCount == 0)
            //{
            //    pld.LoadByOrderAndItem(idoc.OrderID, idoc.ItemID);
            //}

            rp.LoadByReceiveDocID(idoc.RecievDocID);
            PalletLocation pl = new PalletLocation();

            pl.loadByPalletID(rp.PalletID);

            if (pl.RowCount == 0)
            {
                pl.LoadByPrimaryKey(pld.PalletLocationID);
                if (pl.IsColumnNull("PalletID"))
                {
                    pl.PalletID = rp.PalletID;
                    pl.Save();
                }
            }


            if (rp.RowCount == 0)
            {
                XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error");
                return;
            }
            if (rp.RowCount > 0)
            {
                rdoc.QuantityLeft += idoc.Quantity;
                rp.Balance        += idoc.Quantity;

                //Delete from picklistDetail and add to pickListDetailDeleted
                PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId);
                pld.MarkAsDeleted();

                // are we adding it the pick face?
                // if so add it to the balance of the pick face also
                pl.loadByPalletID(rp.PalletID);

                if (pl.RowCount == 0)
                {
                    PutawayLocation plocation = new PutawayLocation(rdoc.ItemID);

                    // we don't have a location for this yet,
                    // select a new location
                    //PutawayLocataion pl = new PutawayLocataion();
                    if (plocation.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        pl.LoadByPrimaryKey(plocation.PalletLocationID);
                        if (pl.RowCount > 0)
                        {
                            pl.PalletID = rp.PalletID;
                            pl.Save();
                        }
                    }
                }

                if (pl.RowCount > 0)
                {
                    PickFace pf = new PickFace();
                    pf.LoadByPalletLocation(pl.ID);
                    if (pf.RowCount > 0)
                    {
                        pf.Balance += Convert.ToInt32(idoc.Quantity);
                        pf.Save();
                    }


                    IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId);
                    idoc.MarkAsDeleted();
                    rdoc.Save();
                    rp.Save();
                    idoc.Save();
                    pld.Save();
                }
                else
                {
                    XtraMessageBox.Show(
                        "This delete is not successful because a free pick face location was not selected. please select a free location and try again.", "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }