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(); }
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); } }
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); } }
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); } }