public ActionResult BookPackItemOperationGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.PPM.BookPackItemOperation item) { item.BookPackItemOperationID = BookPackItemOperationList.Count + 1; item.BookPackItemID = 1; foreach (ModelState modelState in ViewData.ModelState.Values) { modelState.Errors.Clear(); } ModelState.SetModelValue("BookPackItemID", new ValueProviderResult(1, "1", System.Globalization.CultureInfo.CurrentCulture)); if (ModelState.IsValid) { try { bool isValid = true; if (BookRepackPackageItemList.Count == 0) { ViewData["EditError"] = Resources.MainResource.NoRepackItemsSelected; isValid = false; var modelError = new BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic().GetByBookPackID(PackID); return(PartialView("_RepackGridViewPartial", modelError)); } if (item.PackingCalculationTypeID == 2) { if (item.PackingParentID == 0) { ViewData["EditError"] = Resources.MainResource.EnterPackingParentID; isValid = false; } } int totalPackage = TotalPackages(item); BusinessLogicLayer.Entity.PPM.BookPackItem packItem = new BusinessLogicLayer.Entity.PPM.BookPackItem(PackID); BusinessLogicLayer.Entity.PPM.BookPackingOperation package = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(packItem.BookPackingOperationID.Value); BusinessLogicLayer.Entity.PPM.BookPrintingOperation printingOperation = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingOperationID); BusinessLogicLayer.Entity.PPM.PackagingType ptype = new BusinessLogicLayer.Entity.PPM.PackagingType(item.PackagingTypeID.Value); var itemExists = (from c in BookPackItemOperationList where c.PackagingTypeID == item.PackagingTypeID select c).FirstOrDefault(); if (itemExists == null) { if (printingOperation != null) { BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic logic = new BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic(); int totalItems = GetTotalBooksForModel(true); int currentTotal = ptype.BooksPerPackage == 3 && ptype.ExamModelCount == 1 ? GetTotalItemsA3() : GetTotalItems(); int totalPrint = (totalPackage * ptype.BooksPerPackage.Value + currentTotal); int count = new BusinessLogicLayer.Components.PPM.ExamLogic().GetExamModelCount(printingOperation.ExamID.Value); if (count > 1) { totalItems = totalItems * count; } if (totalItems < totalPrint) { isValid = false; ViewData["EditError"] = Resources.MainResource.TotalPackGreaterThanOverallTotal; } } if (isValid) { BusinessLogicLayer.Entity.PPM.BookPackItemOperation entity = new BusinessLogicLayer.Entity.PPM.BookPackItemOperation(); entity.BookPackItemOperationID = BookPackItemOperationList.Count + 1; entity.AllocatedFrom = item.AllocatedFrom; entity.BookPackItemID = packItem.BookPackItemID; entity.PackingParentID = package.BookPackingOperationID; entity.CreatedDate = DateTime.Now; entity.ModifiedDate = DateTime.Now; entity.Name = item.Name; entity.PackingParentID = item.PackingParentID; entity.PackageTotal = totalPackage; entity.PackagingTypeID = item.PackagingTypeID; entity.PackingCalculationTypeID = item.PackingCalculationTypeID; entity.PackingValue = item.PackingValue; BookPackItemOperationList.Add(entity); } } else { ViewData["EditError"] = "لا يمكن ادخال نوع الحزمة مرتين"; } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { string msgError = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { msgError += error.ErrorMessage + " "; } } ViewData["EditError"] = msgError; } var model = BookPackItemOperationList; return(PartialView("_BookPackItemOperationGridViewPartial", model)); }
public ActionResult NumberingPack(FormCollection form) { BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic logic = new BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic(); var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingOperationID); List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> packing = logic.GetPackagingTypeByBookPackID(PackID); List <BusinessLogicLayer.Entity.PPM.PackagingType> packageTypes = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetAll(); var orderedPackageTypes = (from x in packageTypes orderby x.Total descending select x); List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> orderedPack = new List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation>(); List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> oldPacks = logic.GetPackedByBookPackID(PackID); List <BusinessLogicLayer.Entity.PPM.BookPackItem> items = new List <BusinessLogicLayer.Entity.PPM.BookPackItem>(); BusinessLogicLayer.Entity.PPM.Exam exam = new BusinessLogicLayer.Entity.PPM.Exam(model.ExamID.Value); int count = exam.ExamModels.Count; int serial = new BusinessLogicLayer.Components.PPM.BookPackingOperationLogic().GetLastPackSerial(exam.ExamID) + 1; List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> orderedPackSingle = new List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation>(); List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> orderedPackMultiple = new List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation>(); BusinessLogicLayer.Entity.PPM.BookPackItem parentItem = new BusinessLogicLayer.Entity.PPM.BookPackItem(PackID); foreach (BusinessLogicLayer.Entity.PPM.PackagingType pckg in orderedPackageTypes) { var packOrder = (from x in packing where x.PackagingTypeID == pckg.PackagingTypeID && x.PackingCalculationTypeID != 2 select x).FirstOrDefault(); if (packOrder != null && packOrder.HasObject) { if (pckg.ExamModelCount == 1) { orderedPackSingle.Add(packOrder); } else { orderedPackMultiple.Add(packOrder); } orderedPack.Add(packOrder); } } foreach (BusinessLogicLayer.Entity.PPM.BookPackItemOperation pack in orderedPackSingle) { AddItemToPack(items, packageTypes, packing, oldPacks, model, exam, ref count, ref serial, pack, parentItem); } foreach (BusinessLogicLayer.Entity.PPM.BookPackItemOperation pack in orderedPackMultiple) { AddItemToPack(items, packageTypes, packing, oldPacks, model, exam, ref count, ref serial, pack, parentItem); } /* * BusinessLogicLayer.Entity.PPM.PackagingType ptype = new BusinessLogicLayer.Entity.PPM.PackagingType(pack.PackagingTypeID.Value); * foreach(BusinessLogicLayer.Entity.PPM.ExamModelItem modelItem in exam.ExamModels) * { * * for(int j = 0; j < model.PrintsForOneModel; j++) * { * BusinessLogicLayer.Entity.PPM.BookPackItem item = new BusinessLogicLayer.Entity.PPM.BookPackItem(); * item.BookPackingOperationID = pack.BookPackingOperationID; * item.OperationStatusID = * } * } */ Qiyas.BusinessLogicLayer.Components.PPM.BookPackItemLogic itemLogic = new BusinessLogicLayer.Components.PPM.BookPackItemLogic(); itemLogic.SaveItems(items); ViewBag.HasError = false; ViewBag.NotifyMessage = Resources.MainResource.NumberingPackSuccess; return(View("Index", model)); }
public ActionResult NumberingPack(FormCollection form) { bool isValid = CheckPackValid(); if (form.GetValue("PassValidation").AttemptedValue.ToString() == "true") { isValid = true; } if (PrintingOperationID == null || PrintingOperationID == 0) { return(Index()); } var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingOperationID); if (isValid) { int parentID = 0; SaveCurrentLists(out parentID); RepackID = parentID; BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic logic = new BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic(); List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> packing = logic.GetPackagingTypeByBookPackID(PackID); List <BusinessLogicLayer.Entity.PPM.PackagingType> packageTypes = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetAll(); var orderedPackageTypes = (from x in packageTypes orderby x.Total descending select x); List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> orderedPack = new List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation>(); List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> oldPacks = logic.GetPackedByBookPackID(PackID); List <BusinessLogicLayer.Entity.PPM.BookPackItem> items = new List <BusinessLogicLayer.Entity.PPM.BookPackItem>(); BusinessLogicLayer.Entity.PPM.Exam exam = new BusinessLogicLayer.Entity.PPM.Exam(model.ExamID.Value); int count = exam.ExamModels.Count; int serial = new BusinessLogicLayer.Components.PPM.BookPackingOperationLogic().GetLastPackSerial(exam.ExamID) + 1; List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> orderedPackSingle = new List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation>(); List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> orderedPackMultiple = new List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation>(); BusinessLogicLayer.Entity.PPM.BookPackItem parentItem = new BusinessLogicLayer.Entity.PPM.BookPackItem(PackID); foreach (BusinessLogicLayer.Entity.PPM.PackagingType pckg in orderedPackageTypes) { var packOrder = (from x in packing where x.PackagingTypeID == pckg.PackagingTypeID && x.PackingCalculationTypeID != 2 select x).FirstOrDefault(); if (packOrder != null && packOrder.HasObject) { if (pckg.ExamModelCount == 1) { orderedPackSingle.Add(packOrder); } else { orderedPackMultiple.Add(packOrder); } orderedPack.Add(packOrder); } } foreach (BusinessLogicLayer.Entity.PPM.BookPackItemOperation pack in orderedPackSingle) { AddItemToPack(items, packageTypes, packing, oldPacks, model, exam, ref count, ref serial, pack, parentItem, parentID); } foreach (BusinessLogicLayer.Entity.PPM.BookPackItemOperation pack in orderedPackMultiple) { AddItemToPack(items, packageTypes, packing, oldPacks, model, exam, ref count, ref serial, pack, parentItem, parentID); } Qiyas.BusinessLogicLayer.Components.PPM.BookPackItemLogic itemLogic = new BusinessLogicLayer.Components.PPM.BookPackItemLogic(); itemLogic.SaveItems(items); ViewBag.HasError = false; ViewBag.NotifyMessage = Resources.MainResource.NumberingPackSuccess; string url = string.Format("{0}", Url.Action("PrintPacks", "BookPackItemRePack")); url += "/" + RepackID + "/" + PrintingOperationID; //Routedi Dictionary <string, object> dictValues = new Dictionary <string, object>(); dictValues.Add("ID", RepackID); dictValues.Add("PrintingID", PrintingOperationID); RouteValueDictionary routeValueDictionary = new RouteValueDictionary( new { controller = "BookPackItemRePack", action = "PrintPacks", ID = RepackID, PrintingID = PrintingOperationID }); return(RedirectToAction("PrintPacks", routeValueDictionary)); //Response.Redirect(url); //PrintPacks(parentID, PrintingOperationID); } else { ViewBag.HasError = true; ViewBag.NotifyMessage = "يرجي مراجعه الحزم المراد اعادة تحزيمها"; } return(View("Index", model)); }
public ActionResult PackingGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.PPM.BookPackItemOperation item) { //if (ModelState.IsValid) { try { bool isValid = true; if (BookRepackPackageItemList.Count == 0) { ViewData["EditError"] = Resources.MainResource.NoRepackItemsSelected; isValid = false; var modelError = new BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic().GetByBookPackID(PackID); return(PartialView("_RepackGridViewPartial", modelError)); } if (item.PackingCalculationTypeID == 2) { if (item.PackingParentID == 0) { ViewData["EditError"] = Resources.MainResource.EnterPackingParentID; isValid = false; } } int totalPackage = TotalPackages(item); BusinessLogicLayer.Entity.PPM.BookPackItem packItem = new BusinessLogicLayer.Entity.PPM.BookPackItem(PackID); BusinessLogicLayer.Entity.PPM.BookPackingOperation package = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(packItem.BookPackingOperationID.Value); BusinessLogicLayer.Entity.PPM.BookPrintingOperation printingOperation = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingOperationID); BusinessLogicLayer.Entity.PPM.PackagingType ptype = new BusinessLogicLayer.Entity.PPM.PackagingType(item.PackagingTypeID.Value); if (printingOperation != null) { BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic logic = new BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic(); int totalItems = GetTotalBooksForModel(true); int currentTotal = ptype.BooksPerPackage == 3 && ptype.ExamModelCount == 1 ? GetTotalItemsA3() : GetTotalItems(); int totalPrint = (totalPackage * ptype.BooksPerPackage.Value + currentTotal); int count = new BusinessLogicLayer.Components.PPM.ExamLogic().GetExamModelCount(printingOperation.ExamID.Value); if (count > 1) { totalItems = totalItems * count; } if (totalItems < totalPrint) { isValid = false; ViewData["EditError"] = Resources.MainResource.TotalPackGreaterThanOverallTotal; } } if (isValid) { BusinessLogicLayer.Entity.PPM.BookPackItemOperation entity = new BusinessLogicLayer.Entity.PPM.BookPackItemOperation(); entity.BookPackItemOperationID = BookPackItemOperationList.Count + 1; entity.AllocatedFrom = item.AllocatedFrom; entity.BookPackItemID = packItem.BookPackItemID; entity.PackingParentID = package.BookPackingOperationID; entity.CreatedDate = DateTime.Now; entity.ModifiedDate = DateTime.Now; entity.Name = item.Name; entity.PackingParentID = package.PackageTotal; entity.PackageTotal = totalPackage; entity.PackagingTypeID = item.PackagingTypeID; entity.PackingCalculationTypeID = item.PackingCalculationTypeID; entity.PackingValue = item.PackingValue; BookPackItemOperationList.Add(entity); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } //else // ViewData["EditError"] = "Please, correct all errors."; var model = BookPackItemOperationList;//new BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic().GetByBookPackID(PackID); return(PartialView("_RepackGridViewPartial", model)); }