Example #1
0
        private void AutoFillCarton(List <PackingList> lstPackingList)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    //PackingListSizeQtyBO obj = new PackingListSizeQtyBO();
                    //obj.PackingList = PackingListID;

                    //List<PackingListSizeQtyBO> lstPackingListSizeQty = obj.SearchObjects();

                    foreach (PackingList item in lstPackingList)
                    {
                        foreach (PackingListViewBO plv in item.ListPackingList)
                        {
                            List <PackingListSizeQtyBO> lstPackingListSizeQty = (new PackingListSizeQtyBO()).GetAllObject().Where(o => o.PackingList == plv.PackingList).ToList();

                            foreach (PackingListSizeQtyBO plsq in lstPackingListSizeQty)
                            {
                                PackingListCartonItemBO objPackListCartonItem = new PackingListCartonItemBO();
                                objPackListCartonItem.PackingList = plsq.PackingList;
                                objPackListCartonItem.Size        = plsq.Size;
                                List <PackingListCartonItemBO> lstCartonItem = objPackListCartonItem.SearchObjects();

                                if (!lstCartonItem.Any())
                                {
                                    // no records
                                    PackingListCartonItemBO objPackListCartonItemToSave = new PackingListCartonItemBO(this.ObjContext);
                                    objPackListCartonItemToSave.PackingList = objPackListCartonItem.PackingList;
                                    objPackListCartonItemToSave.Size        = objPackListCartonItem.Size;
                                    objPackListCartonItemToSave.Count       = plsq.Qty;
                                }
                                else if (lstCartonItem.Any())// && (lstCartonItem.SingleOrDefault().Count <plsq.objPackingList.bjOrderDetailQty.Qty))
                                {
                                    //update
                                    PackingListCartonItemBO objPackListCartonItemToSave = new PackingListCartonItemBO(this.ObjContext);
                                    objPackListCartonItemToSave.ID = lstCartonItem.SingleOrDefault().ID;
                                    objPackListCartonItemToSave.GetObject();

                                    objPackListCartonItemToSave.Count = plsq.Qty;
                                }
                            }
                        }
                    }
                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while Saving PackingListCartonItem From ViewPackingLists.aspx Page when click AutoFillCarton Function", ex);
            }
        }
Example #2
0
        private List <PackingListBO> GetPolyBagData()
        {
            List <PackingListBO>           PackingLists   = new List <PackingListBO>();
            List <PackingListCartonItemBO> lstCartonItems = new List <PackingListCartonItemBO>();

            PackingListBO objPacking = new PackingListBO();

            if (Source != null)
            {
                PackingLists = Source;
            }
            else
            {
                OrderDetailQtyBO obj = new OrderDetailQtyBO();
                obj.ID = this.OrderDetailQtyID;
                obj.GetObject();

                this.SizeID = obj.Size;

                var objPack = new PackingListBO();
                //objPack.WeeklyProductionCapacity = WeekendCapacityID;
                objPack.OrderDetail = obj.OrderDetail;
                //objPack.CartonNo = CartonNo;

                DateTime monday = WeekEndDate.AddDays(-(int)WeekEndDate.DayOfWeek - 6);

                // List<PackingListBO> loadedPackingLists = objPack.SearchObjects().Where(m => m.PackingListSizeQtysWhereThisIsPackingList.Where(o => o.Qty > 0).Select(s => s.Size).Contains(this.SizeID) && m.objWeeklyProductionCapacity.WeekendDate.Date == WeekEndDate.Date && m.CartonNo > 0).ToList(); //.Where(m => m.PackingListCartonItemsWhereThisIsPackingList.Where(k => k.Size == this.SizeID).SingleOrDefault().Count < m.PackingListSizeQtysWhereThisIsPackingList.Where(k => k.Size == this.SizeID).SingleOrDefault().Qty).ToList();

                List <PackingListBO> loadedPackingLists = objPack.SearchObjects().Where(m => m.PackingListSizeQtysWhereThisIsPackingList.Where(s => s.Qty > 0).Select(s => s.Size).Contains(this.SizeID) && (DateTime.Compare(m.objWeeklyProductionCapacity.WeekendDate.Date, monday.Date) > -1) && m.CartonNo > 0).ToList(); //.Where(m => m.PackingListCartonItemsWhereThisIsPackingList.Where(k => k.Size == this.SizeID).SingleOrDefault().Count < m.PackingListSizeQtysWhereThisIsPackingList.Where(k => k.Size == this.SizeID).SingleOrDefault().Qty).ToList();

                foreach (PackingListBO objPackingList in loadedPackingLists)
                {
                    PackingListCartonItemBO objCartonItem = new PackingListCartonItemBO();
                    objCartonItem.Size        = this.SizeID;
                    objCartonItem.PackingList = objPackingList.ID;
                    objCartonItem.Count       = this.ItemNo;

                    lstCartonItems = objCartonItem.SearchObjects();

                    if (lstCartonItems.Any() && lstCartonItems.Count == 1)
                    {
                        this.polyBagStatus = PolyBagFillingStatus.Filled;
                        break;
                    }
                    else
                    {
                        PackingLists.Add(objPackingList);
                        this.polyBagStatus = PolyBagFillingStatus.Available;
                    }
                }
            }

            if (this.polyBagStatus == PolyBagFillingStatus.Filled)
            {
                PackingLists.Clear();
            }

            Source = PackingLists;

            return(PackingLists);
        }
Example #3
0
        private void ChangeOrderDetails(int orderdetail, int invoiceorder)
        {
            try
            {
                if (orderdetail > 0)
                {
                    InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO(this.ObjContext);
                    objInvoiceOrder.ID = invoiceorder;
                    objInvoiceOrder.GetObject();

                    DateTime nextmonday = objInvoiceOrder.objOrderDetail.SheduledDate.AddDays(7 - objInvoiceOrder.objOrderDetail.SheduledDate.DayOfWeek == DayOfWeek.Monday ? 7 : (int)objInvoiceOrder.objOrderDetail.SheduledDate.DayOfWeek);

                    using (TransactionScope ts = new TransactionScope())
                    {
                        PackingListBO objPList = new PackingListBO();
                        objPList.OrderDetail = orderdetail;

                        List <PackingListBO> lstPackingLists = objPList.SearchObjects();

                        foreach (PackingListBO objpl in lstPackingLists)
                        {
                            PackingListSizeQtyBO objPlsq = new PackingListSizeQtyBO();
                            objPlsq.PackingList = objpl.ID;
                            List <PackingListSizeQtyBO> lstPackingListSizeQty = objPlsq.SearchObjects();

                            // delete the PackingListSizeQtyBO details
                            foreach (PackingListSizeQtyBO objplsqi in lstPackingListSizeQty)
                            {
                                PackingListSizeQtyBO objPackingListSizeQtyItem = new PackingListSizeQtyBO(this.ObjContext);
                                objPackingListSizeQtyItem.ID = objplsqi.ID;
                                objPackingListSizeQtyItem.GetObject();

                                objPackingListSizeQtyItem.Delete();
                            }

                            //this.ObjContext.SaveChanges();

                            PackingListCartonItemBO objPLCI = new PackingListCartonItemBO();
                            objPLCI.PackingList = objpl.ID;
                            List <PackingListCartonItemBO> lstPackingListCartonItems = objPLCI.SearchObjects();

                            // delete the PackingListCartonItemBO details
                            foreach (PackingListCartonItemBO objplci in lstPackingListCartonItems)
                            {
                                PackingListCartonItemBO objPackingListCartonItem = new PackingListCartonItemBO(this.ObjContext);
                                objPackingListCartonItem.ID = objplci.ID;
                                objPackingListCartonItem.GetObject();

                                objPackingListCartonItem.Delete();
                            }

                            //this.ObjContext.SaveChanges();

                            // delete the PackingListBO details

                            PackingListBO objPackingList = new PackingListBO(this.ObjContext);
                            objPackingList.ID = objpl.ID;
                            objPackingList.GetObject();

                            objPackingList.Delete();
                        }

                        //Creating new packing list record for next week
                        List <WeeklyProductionCapacityBO> lstwpc = (new WeeklyProductionCapacityBO()).SearchObjects().Where(o => o.WeekendDate >= nextmonday && o.WeekendDate <= nextmonday.AddDays(7)).ToList();

                        PackingListBO objp = new PackingListBO();
                        objp.WeeklyProductionCapacity = lstwpc[0].ID;

                        List <PackingListBO> lst = objp.SearchObjects();

                        if (lst.Count > 0)
                        {
                            PackingListBO objNewPl = new PackingListBO(this.ObjContext);
                            objNewPl.Carton      = 1;
                            objNewPl.CartonNo    = 0;
                            objNewPl.CreatedDate = objNewPl.ModifiedDate = DateTime.Now;
                            objNewPl.Creator     = objNewPl.Modifier = this.LoggedUser.ID;
                            objNewPl.OrderDetail = orderdetail;
                            objNewPl.WeeklyProductionCapacity = lstwpc[0].ID;
                            objNewPl.PackingQty = 0;

                            this.ObjContext.SaveChanges();

                            int Newplid = objNewPl.ID;

                            OrderDetailQtyBO objOrderDetailqty = new OrderDetailQtyBO();
                            objOrderDetailqty.OrderDetail = orderdetail;

                            List <OrderDetailQtyBO> lstOrderDetailsQty = objOrderDetailqty.SearchObjects();

                            foreach (OrderDetailQtyBO objOdq in lstOrderDetailsQty)
                            {
                                if (objOdq.Qty > 0)
                                {
                                    PackingListSizeQtyBO objPackingListSizeQty = new PackingListSizeQtyBO(this.ObjContext);
                                    objPackingListSizeQty.PackingList = Newplid;
                                    objPackingListSizeQty.Size        = objOdq.Size;
                                }
                            }
                        }
                        //this.ObjContext.SaveChanges();

                        //change the shipment date, scheduled date
                        OrderDetailBO objOrderDetail = new OrderDetailBO(this.ObjContext);
                        objOrderDetail.ID = orderdetail;
                        objOrderDetail.GetObject();

                        objOrderDetail.SheduledDate = nextmonday;
                        objOrderDetail.ShipmentDate = nextmonday;

                        this.ObjContext.SaveChanges();

                        ts.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while deleting or adding packing list details and changing the shipment date and scheduled date from the AddEditInvoce.aspx", ex);
            }
        }