public PackingList ConvertBO(PackingListBO packingListBO) { if (packingListBO == null) { return(null); } return(new PackingList() { Id = packingListBO.Id, PackingName = packingListBO.PackingName, CreatorName = packingListBO.CreatorName, DeliveryAddress = packingListBO.DeliveryAddress, DeliveryDate = packingListBO.DeliveryDate, ItemType = packingListBO.ItemType, FreightType = packingListBO.FreightType, IsActive = packingListBO.IsActive, Projects = packingListBO.ProjectIds?.Select(pID => new ProjectPackingList() { ProjectID = pID, PackingListID = packingListBO.Id }).ToList(), ColliLists = packingListBO.ColliListIds?.Select(clID => new PackingColliList() { ColliListID = clID, PackingListID = packingListBO.Id }).ToList(), PackItems = packingListBO.PackItemsIds?.Select(piID => new PackItem() { PackingListId = packingListBO.Id }).ToList() }); }
public void UpdatePassTest() { try { var originalPackingList = getPackingListMock(); originalPackingList = service.Create(originalPackingList); var newPackingList = new PackingListBO(); newPackingList.Id = originalPackingList.Id; newPackingList.ItemType = originalPackingList.ItemType; newPackingList.FreightType = originalPackingList.FreightType; newPackingList.ItemType = "Light air"; newPackingList = service.Update(newPackingList); var updatedPackingList = service.Get(originalPackingList.Id); Assert.Equal(originalPackingList.Id, newPackingList.Id); Assert.Equal("Light air", newPackingList.ItemType); Assert.Equal(newPackingList.ItemType, updatedPackingList.ItemType); Assert.NotEqual(originalPackingList.ItemType, newPackingList.ItemType); } catch (Exception e) { Assert.True(false, e.Message); } finally { clearDb(); } }
private List <PackingListBO> GetCartonData() { var PackingLists = new List <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; PackingLists = objPack.SearchObjects().ToList(); } Source = PackingLists; return(PackingLists); }
protected void btnResetPacking_Click(object sender, EventArgs e) { List <PackingListBO> lstPackingLists = GetPolyBagData(); var objPackBO = new PackingListBO(); objPackBO.WeeklyProductionCapacity = WeekendCapacityID; objPackBO.CartonNo = CartonNo; lstPackingLists = objPackBO.SearchObjects().ToList(); foreach (PackingListBO objPack in lstPackingLists) { List <int> lstPackListCartonItemQtys = objPack.PackingListCartonItemsWhereThisIsPackingList.Select(m => m.ID).ToList(); foreach (int id in lstPackListCartonItemQtys) { PackingListCartonItemBO obj = new PackingListCartonItemBO(this.ObjContext); obj.ID = id; obj.GetObject(); obj.Delete(); } } this.ObjContext.SaveChanges(); }
public IActionResult Post([FromBody] PackingListBO packingList) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(facade.PackingListService.Create(packingList))); }
private PackingListBO getPackingListMock() { PackingListBO packingList = new PackingListBO() { ItemType = "Cylinder", FreightType = "Mega tough" }; return(packingList); }
private void PopulateDataGrid() { List <ReturnCartonsDetailsViewBO> lstReturnCartonsDetailsView = new List <ReturnCartonsDetailsViewBO>(); lstReturnCartonsDetailsView = PackingListBO.GetCartonsDetails(this.WeekEndDate); List <IGrouping <int, ReturnCartonsDetailsViewBO> > lstGroupReturnCartonsDetails = lstReturnCartonsDetailsView.GroupBy(m => (int)m.ShipTo).ToList(); this.rptShipmentOrders.DataSource = lstGroupReturnCartonsDetails; this.rptShipmentOrders.DataBind(); }
public PackingListBO Create(PackingListBO packingList) { if (packingList == null) { return(null); } using (var uow = _facade.UnitOfWork) { var createdPackingList = uow.PackingListRepository.Create(_convPL.ConvertBO(packingList)); uow.Complete(); return(_convPL.Convert(createdPackingList)); } }
private void PopulateDataGrid() { List <PackingList> PackingLists = new List <PackingList>(); List <PackingListViewBO> lstPackingLists = new List <PackingListViewBO>(); lstPackingLists = PackingListBO.GetPackingList(this.WeekEndDate); IEnumerable <IGrouping <int?, PackingListViewBO> > lst = lstPackingLists.GroupBy(m => m.CartonNo).ToList(); foreach (IGrouping <int?, PackingListViewBO> objPackingList in lst) { PackingList objPackingListItem = new PackingList(); objPackingListItem.CartonNo = objPackingList.Key.Value; foreach (PackingListViewBO item in objPackingList) { objPackingListItem.ListPackingList.Add(item); } PackingLists.Add(objPackingListItem); } if (PackingLists.Any()) { Source = PackingLists; this.rptPackingList.DataSource = PackingLists; this.rptPackingList.DataBind(); litGrandTotal.Text = "Grand Total: " + grandTotal; } else { dvEmptyContent.Visible = true; this.btnPrintLabels.Visible = false; this.btnViewCartons.Visible = false; this.btnStartPacking.Visible = false; } /* if (PackingLists.Where(m => m.CartonNo == 0).Count() > 0) * { * this.btnPrintLabels.Visible = false; * this.btnViewCartons.Visible = false; * this.btnStartPacking.Visible = false; * }*/ }
protected void btnReset_Click(object sender, EventArgs e) { //NNM int carton = int.Parse(this.hdnCarton.Value); int week = int.Parse(this.hdnWeekID.Value); try { if (carton > 0 && week > 0) { List <PackingListBO> lstPackingLists = GetPolyBagData(); var objPackBO = new PackingListBO(); objPackBO.WeeklyProductionCapacity = week; objPackBO.CartonNo = carton; lstPackingLists = objPackBO.SearchObjects().ToList(); using (TransactionScope ts = new TransactionScope()) { foreach (PackingListBO objPack in lstPackingLists) { List <int> lstPackListCartonItemQtys = objPack.PackingListCartonItemsWhereThisIsPackingList.Select(m => m.ID).ToList(); foreach (int id in lstPackListCartonItemQtys) { PackingListCartonItemBO obj = new PackingListCartonItemBO(this.ObjContext); obj.ID = id; obj.GetObject(); obj.Delete(); } } this.ObjContext.SaveChanges(); ts.Complete(); } } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while deleting PackingListCartonItems in PackingList.aspx", ex); } }
public IActionResult Put(int id, [FromBody] PackingListBO packingList) { if (id != packingList.Id) { return(BadRequest("Path ID does not match packing list ID in JSON object.")); } try { var updatedPackingList = facade.PackingListService.Update(packingList); if (updatedPackingList == null) { return(StatusCode(404, "No packing list found with that ID")); } return(Ok(updatedPackingList)); } catch (Exception e) { return(StatusCode(404, e.Message + "/n" + e.StackTrace)); } }
protected void rptCarton_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is PackingListBO) { PackingListBO objPacking = (PackingListBO)item.DataItem; Literal litCartonNo = (Literal)item.FindControl("litCartonNo"); litCartonNo.Text = "පෙට්ටිය " + objPacking.CartonNo.ToString() + "<br/>Carton " + objPacking.CartonNo.ToString(); HiddenField hdnCartonNo = (HiddenField)item.FindControl("hdnCartonNo"); hdnCartonNo.Value = objPacking.CartonNo.ToString(); Image imgCarton = (Image)item.FindControl("imgCarton"); imgCarton.Attributes.Add("cid", objPacking.CartonNo.ToString()); //HyperLink linkReset = (HyperLink)item.FindControl("linkReset"); //linkReset.Attributes.Add("cid", objPacking.CartonNo.ToString()); //linkReset.Attributes.Add("wid", objPacking.WeeklyProductionCapacity.ToString()); } }
/// <summary> /// Populate the controls. /// </summary> private void PopulateControls() { litHeaderText.Text = "Packing List For " + WeekEndDate.ToString("dd/MM/yyyy"); // this.ActivePage.Heading; this.ddlShipmentMode.Items.Clear(); this.ddlShipmentMode.Items.Add(new ListItem("Select a Shipment Mode", "0")); List <ShipmentModeBO> lstShipmentModes = (new ShipmentModeBO()).GetAllObject().ToList(); foreach (ShipmentModeBO sm in lstShipmentModes) { this.ddlShipmentMode.Items.Add(new ListItem(sm.Name, sm.ID.ToString())); } this.ddlShippingAddress.Items.Clear(); this.ddlShippingAddress.Items.Add(new ListItem("Select Shipping Address", "0")); List <ReturnShippingAddressWeekendDateBO> lstShippingAddresses = PackingListBO.GetShippingAddressWeekendDate(this.WeekEndDate); foreach (ReturnShippingAddressWeekendDateBO sa in lstShippingAddresses) { this.ddlShippingAddress.Items.Add(new ListItem(sa.CompanyName, sa.ID.ToString())); } this.PopulateDataGrid(); }
protected void rptPackingList_ItemCommand(object source, RepeaterCommandEventArgs e) { HiddenField hdnCartonNo = (HiddenField)e.Item.FindControl("hdnCartonNo"); int cartonNo = int.Parse(hdnCartonNo.Value.ToString()); if (Source != null) { List <PackingList> PackingList = Source.Where(m => m.CartonNo == cartonNo).ToList(); if (e.CommandName == "PrintLabel") { this.GenerateLabels(PackingList); } else if (e.CommandName == "StartPacking") { Response.Redirect("FillCarton.aspx?cartonNo=" + cartonNo + "&&weekendDate=" + WeekEndDate.ToShortDateString()); } else if (e.CommandName == "AutoFill") { //HiddenField hdnPackingListID = (HiddenField)e.Item.FindControl("hdnPackingListID"); // Auto filling the carton this.AutoFillCarton(PackingList); this.PopulateDataGrid(); } else if (e.CommandName == "ResetCarton") { HiddenField hdnWeeklyID = (HiddenField)e.Item.FindControl("hdnWeeklyID"); int weeklyid = int.Parse(hdnWeeklyID.Value); try { if (cartonNo > 0 && weeklyid > 0) { //List<PackingListBO> lstPackingLists = GetPolyBagData(); PackingListBO objPackBO = new PackingListBO(); objPackBO.WeeklyProductionCapacity = weeklyid; objPackBO.CartonNo = cartonNo; List <PackingListBO> lstPackingLists = objPackBO.SearchObjects().ToList(); using (TransactionScope ts = new TransactionScope()) { foreach (PackingListBO objPack in lstPackingLists) { List <int> lstPackListCartonItemQtys = objPack.PackingListCartonItemsWhereThisIsPackingList.Select(m => m.ID).ToList(); foreach (int id in lstPackListCartonItemQtys) { PackingListCartonItemBO obj = new PackingListCartonItemBO(this.ObjContext); obj.ID = id; obj.GetObject(); obj.Delete(); } } this.ObjContext.SaveChanges(); ts.Complete(); } } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while deleting PackingListCartonItems in ViewPackingLists.aspx", ex); } this.PopulateDataGrid(); } } else { Response.Redirect(Request.RawUrl); } }
public void reset() { packingList = new PackingListBO(); }
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); }
private void PopulateDataGrid() { //List<PackingList> PackingLists = new List<PackingList>(); List <PackingListViewBO> lstPackingLists = new List <PackingListViewBO>(); if (int.Parse(this.ddlShipmentMode.SelectedValue) > 0 || int.Parse(this.ddlShippingAddress.SelectedValue) > 0) { lstPackingLists = PackingListBO.GetPackingList(this.WeekEndDate, int.Parse(this.ddlShipmentMode.SelectedValue), int.Parse(this.ddlShippingAddress.SelectedValue)); if (lstPackingLists.Count > 0) { //IEnumerable<IGrouping<int?, PackingListViewBO>> lst = lstPackingLists.GroupBy(m => m.CartonNo).ToList(); //List<IGrouping<int, PackingListViewBO>> lst = lstPackingLists.GroupBy(m => m.CartonNo).ToList(); //Source = lstPackingLists; //this.rptPackingList.DataSource = lstPackingLists.GroupBy(m => m.CartonNo).ToList(); //this.rptPackingList.DataBind(); this.rptDistributor.DataSource = lstPackingLists.GroupBy(m => m.ShipTo).ToList(); this.rptDistributor.DataBind(); this.litGrandTotal.Visible = true; this.dvEmptyContent.Visible = false; this.btnPrintLabels.Visible = true; this.btnViewCartons.Visible = true; this.btnStartPacking.Visible = true; this.litGrandTotal.Visible = true; this.rptDistributor.Visible = true; } else { this.litErrorMeassaage.Text = "No Packing list details found."; this.dvEmptyContent.Visible = true; this.btnPrintLabels.Visible = false; this.btnViewCartons.Visible = false; this.btnStartPacking.Visible = false; this.litGrandTotal.Visible = false; this.rptDistributor.Visible = false; } } else { this.litErrorMeassaage.Text = "Please select Shipment Mode and Shipping Address"; this.dvEmptyContent.Visible = true; this.btnPrintLabels.Visible = false; this.btnViewCartons.Visible = false; this.btnStartPacking.Visible = false; this.litGrandTotal.Visible = false; this.rptDistributor.Visible = false; } litGrandTotal.Text = "Grand Total: " + grandTotal; //NNM /* foreach (IGrouping<int?, PackingListViewBO> objPackingList in lst) * { * PackingList objPackingListItem = new PackingList(); * objPackingListItem.CartonNo = objPackingList.Key.Value; * * foreach (PackingListViewBO item in objPackingList) * { * objPackingListItem.ListPackingList.Add(item); * } * * PackingLists.Add(objPackingListItem); * }*/ /*if (PackingLists.Any()) * { * Source = PackingLists; * * this.rptPackingList.DataSource = PackingLists; * this.rptPackingList.DataBind(); * * * }*/ /* else * { * dvEmptyContent.Visible = true; * this.btnPrintLabels.Visible = false; * this.btnViewCartons.Visible = false; * this.btnStartPacking.Visible = false; * }*/ /* if (PackingLists.Where(m => m.CartonNo == 0).Count() > 0) * { * this.btnPrintLabels.Visible = false; * this.btnViewCartons.Visible = false; * this.btnStartPacking.Visible = false; * }*/ }
public PackingListBO Update(PackingListBO packingList) { if (packingList == null) { return(null); } using (var uow = _facade.UnitOfWork) { var packingListEnt = uow.PackingListRepository.Get(packingList.Id); if (packingListEnt == null) { return(null); } var packingListUpdated = _convPL.ConvertBO(packingList); packingListEnt.Id = packingListUpdated.Id; packingListEnt.PackingName = packingListUpdated.PackingName; packingListEnt.CreatorName = packingListUpdated.CreatorName; packingListEnt.DeliveryAddress = packingListUpdated.DeliveryAddress; packingListEnt.DeliveryDate = packingListUpdated.DeliveryDate; packingListEnt.ItemType = packingListUpdated.ItemType; packingListEnt.FreightType = packingListUpdated.FreightType; packingListEnt.IsActive = packingListUpdated.IsActive; if (packingListUpdated != null) { //Related to Project relation packingListEnt.Projects.RemoveAll( pu => !packingListUpdated.Projects.Exists( p => p.ProjectID == pu.ProjectID && p.PackingListID == pu.PackingListID)); packingListUpdated.Projects.RemoveAll( pu => packingListEnt.Projects.Exists( p => p.ProjectID == pu.ProjectID && p.PackingListID == pu.PackingListID)); packingListEnt.Projects.AddRange( packingListUpdated.Projects); //Related to ColliList packingListEnt.ColliLists.RemoveAll( pu => !packingListUpdated.ColliLists.Exists( p => p.ColliListID == pu.ColliListID && p.PackingListID == pu.PackingListID)); packingListUpdated.ColliLists.RemoveAll( pu => packingListEnt.ColliLists.Exists( p => p.ColliListID == pu.ColliListID && p.PackingListID == pu.PackingListID)); packingListEnt.ColliLists.AddRange( packingListUpdated.ColliLists); } uow.Complete(); return(_convPL.Convert(packingListEnt)); } }
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); } }