public ActionResult RepackGroup(int bookPrintingId, int repackFrom, int repackTo) { BusinessLogicLayer.Components.PPM.BookPackingOperationLogic BookPackingOperationLogic = new BusinessLogicLayer.Components.PPM.BookPackingOperationLogic(); BusinessLogicLayer.Components.PPM.BookPackItemLogic packItemLogic = new BusinessLogicLayer.Components.PPM.BookPackItemLogic(); BusinessLogicLayer.Components.PPM.BookPackItemLogic BookPackItemLogic = new BusinessLogicLayer.Components.PPM.BookPackItemLogic(); BusinessLogicLayer.Entity.PPM.BookPackingOperation operation = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(); BookRepackPackageItemList.Clear(); BookPackItemOperationList.Clear(); List <BusinessLogicLayer.Entity.PPM.BookPackItem> bookPackItems = new List <BusinessLogicLayer.Entity.PPM.BookPackItem>(); PrintingOperationID = bookPrintingId; var pitems = BookPackItemLogic.GetAllByPrintingIDandPackagingTypeIDStored(bookPrintingId, repackFrom); int packOperationID = 0; string name; foreach (var item in pitems) { var addedItem = repackItemLogic.GetBookRepackItem(item.PackCode); BookRepackPackageItemList.Add(addedItem); PackID = item.BookPackItemID; packOperationID = item.BookPackingOperationID.Value; } BookPackItemOperationGridViewPartialAddNew(new BusinessLogicLayer.Entity.PPM.BookPackItemOperation() { PackagingTypeID = repackTo, PackingCalculationTypeID = 1, PackingValue = 100 }); FormCollection newFormCollection = new FormCollection(); newFormCollection.Add("PassValidation", "true"); var actionResult = NumberingPack(newFormCollection); return(actionResult); }
public ActionResult SaveWeight(string item, decimal weight) { var itemPack = new BusinessLogicLayer.Entity.PPM.BookPackItem(item); //if (itemPack.OperationStatusID > 3) // return Json("notsaved"); if (itemPack.HasObject) { BusinessLogicLayer.Components.PPM.PackageWeightLogic logic = new BusinessLogicLayer.Components.PPM.PackageWeightLogic(); var packageOperation = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(itemPack.BookPackingOperationID.Value); if (itemPack.OperationStatusID == 2) { itemPack.OperationStatusID = 3; } itemPack.Weight = weight; itemPack.Save(); BusinessLogicLayer.Entity.PPM.PackageWeight package = new BusinessLogicLayer.Entity.PPM.PackageWeight(item); if (!package.HasObject) { package = new BusinessLogicLayer.Entity.PPM.PackageWeight(); package.CreatedDate = DateTime.Now; } package.ModifiedDate = DateTime.Now; package.PackageCode = itemPack.BookPackItemID; package.Weight = weight; package.Save(); logic.CheckPackWeightCompleted(packageOperation.BookPrintingOperationID.Value); return(Json("saved")); } else { return(Json("notsaved")); } }
public ActionResult BookPrintingOperationGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.PPM.BookPrintingOperation item) { if (ModelState.IsValid) { try { if ((item.ExamsNeededForA3.Value % 3) != 0) { ViewData["EditError"] = "يجب ان يكون الايه 3 من مضاعفات الثلاثة"; } else { BusinessLogicLayer.Entity.PPM.BookPrintingOperation printing = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(); printing.ExamsNeededForA3 = item.ExamsNeededForA3; printing.ExamsNeededForA4 = item.ExamsNeededForA4; printing.ExamsNeededForCD = item.ExamsNeededForCD; printing.ExamID = item.ExamID; printing.Name = item.Name; printing.OperationStatusID = (int)OperationStatus.Printing; printing.PrintsForOneModel = item.PrintsForOneModel; printing.ModifiedDate = DateTime.Now; printing.CreatedDate = DateTime.Now; printing.Save(); if (!BookPackingOperationLogic.HaveA3Packs(printing.BookPrintingOperationID) && printing.ExamsNeededForA3 > 0) { BusinessLogicLayer.Entity.PPM.BookPackingOperation pack = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(); BusinessLogicLayer.Entity.PPM.Exam exam = new BusinessLogicLayer.Entity.PPM.Exam(printing.ExamID.Value); BusinessLogicLayer.Entity.PPM.PackagingType ptype = new BusinessLogicLayer.Entity.PPM.PackagingType(1, 3); if (ptype.HasObject) { pack.BookPrintingOperationID = printing.BookPrintingOperationID; pack.CreatedDate = DateTime.Now; pack.ModifiedDate = DateTime.Now; pack.NumberofBooksPerModel = printing.ExamsNeededForA3; pack.PackageTotalPerModel = printing.ExamsNeededForA3 / 3; //pack.PackageTotal = pack.PackageTotalPerModel * exam.ExamModels.Count; pack.PackageTotal = pack.PackageTotalPerModel; pack.PackagingTypeID = ptype.PackagingTypeID; pack.PackingCalculationTypeID = 1; pack.PackingValue = 100; pack.Save(); } } } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = Resources.MainResource.PleaseCorrectErrors; } var model = new BusinessLogicLayer.Components.PPM.BookPrintingOperationLogic().GetAll(); return(PartialView("_BookPrintingOperationGridViewPartial", model)); }
public ActionResult BookPrintingOperationGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.PPM.BookPrintingOperation item) { if (ModelState.IsValid) { try { if (item.OperationStatusID > 1) { ViewData["EditError"] = "حالة الطلب يجب ان تكون طباعة للسماح بالتعديل"; var modelErr = new BusinessLogicLayer.Components.PPM.BookPrintingOperationLogic().GetAll(); return(PartialView("_BookPrintingOperationGridViewPartial", modelErr)); } BusinessLogicLayer.Entity.PPM.BookPrintingOperation printing = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(item.BookPrintingOperationID); printing.ExamsNeededForA3 = item.ExamsNeededForA3; printing.ExamsNeededForA4 = item.ExamsNeededForA4; printing.ExamsNeededForCD = item.ExamsNeededForCD; printing.ExamID = item.ExamID; printing.Name = item.Name; printing.PrintsForOneModel = item.PrintsForOneModel; printing.ModifiedDate = DateTime.Now; printing.CreatedDate = DateTime.Now; printing.Save(); if (!BookPackingOperationLogic.HaveA3Packs(printing.BookPrintingOperationID)) { BusinessLogicLayer.Entity.PPM.BookPackingOperation pack = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(); BusinessLogicLayer.Entity.PPM.Exam exam = new BusinessLogicLayer.Entity.PPM.Exam(printing.ExamID.Value); BusinessLogicLayer.Entity.PPM.PackagingType ptype = new BusinessLogicLayer.Entity.PPM.PackagingType(1, 3); if (ptype.HasObject) { pack.BookPrintingOperationID = printing.BookPrintingOperationID; pack.CreatedDate = DateTime.Now; pack.ModifiedDate = DateTime.Now; pack.NumberofBooksPerModel = printing.ExamsNeededForA3; pack.PackageTotalPerModel = printing.ExamsNeededForA3 / 3; pack.PackageTotal = pack.PackageTotalPerModel * exam.ExamModels.Count; pack.PackagingTypeID = ptype.PackagingTypeID; pack.PackingCalculationTypeID = 1; pack.PackingValue = 100; pack.Save(); } } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var model = new BusinessLogicLayer.Components.PPM.BookPrintingOperationLogic().GetAll(); return(PartialView("_BookPrintingOperationGridViewPartial", model)); }
public ActionResult CheckItem(string item) { var itemPack = new BusinessLogicLayer.Entity.PPM.BookPackItem(item); if (itemPack == null || !itemPack.HasObject) { PackID = 0; PrintingOperationID = 0; return(Json("notexists")); } if (itemPack.ParentID != null) { PackID = 0; PrintingOperationID = 0; return(Json("notexists")); } PackID = itemPack.BookPackItemID; BusinessLogicLayer.Entity.PPM.BookPackingOperation operation = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(itemPack.BookPackingOperationID.Value); BusinessLogicLayer.Entity.PPM.BookPrintingOperation printing = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(operation.BookPrintingOperationID.Value); PrintingOperationID = operation.BookPrintingOperationID.Value; int countExams = new BusinessLogicLayer.Components.PPM.ExamLogic().GetExamModelCount(printing.ExamID.Value); if (countExams > ExamCount) { ExamCount = countExams; } var addedItem = repackItemLogic.GetBookRepackItem(item); var exItem = BookRepackPackageItemList.Where(c => c.ExamID == addedItem.ExamID).FirstOrDefault(); if (BookRepackPackageItemList.Count > 0 && exItem == null) { return(Json("notexists")); } BookRepackPackageItemList.Add(addedItem); if (itemPack.HasObject) { return(Json("exists")); } else { return(Json("notexists")); } //var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingOperationID); //model.OperationStatusID = 2; //model.Save(); //ViewBag.HasError = false; //ViewBag.NotifyMessage = Resources.MainResource.SaveSuccess; }
public ActionResult CheckItem(string item) { var itemPack = new BusinessLogicLayer.Entity.PPM.BookPackItem(item); if (itemPack == null || !itemPack.HasObject) { PackID = 0; PrintingOperationID = 0; return(Json("notexists")); } if (itemPack.ParentID != null) { PackID = 0; PrintingOperationID = 0; return(Json("notexists")); } PackID = itemPack.BookPackItemID; BusinessLogicLayer.Entity.PPM.BookPackingOperation operation = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(itemPack.BookPackingOperationID.Value); PrintingOperationID = operation.BookPrintingOperationID.Value; BookRepackPackageItemList.Add(repackItemLogic.GetBookRepackItem(item)); if (itemPack.HasObject) { return(Json("exists")); } else { return(Json("notexists")); } //var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingOperationID); //model.OperationStatusID = 2; //model.Save(); //ViewBag.HasError = false; //ViewBag.NotifyMessage = Resources.MainResource.SaveSuccess; }
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)); }
private void AddItemToPack(List <BusinessLogicLayer.Entity.PPM.BookPackItem> items, List <BusinessLogicLayer.Entity.PPM.PackagingType> packageTypes, List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> packing, List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> oldPacks, BusinessLogicLayer.Entity.PPM.BookPrintingOperation model, BusinessLogicLayer.Entity.PPM.Exam exam, ref int count, ref int serial, BusinessLogicLayer.Entity.PPM.BookPackItemOperation pack, BusinessLogicLayer.Entity.PPM.BookPackItem parentItem, int parentRepackID) { serial = 1; BusinessLogicLayer.Components.PPM.BookPackItemLogic BookPackItemLogic = new BusinessLogicLayer.Components.PPM.BookPackItemLogic(); foreach (BusinessLogicLayer.Entity.PPM.BookRepackPackageItem vparentItem in BookRepackPackageItemList) { parentItem = new BusinessLogicLayer.Entity.PPM.BookPackItem(vparentItem.BookPackItemID.Value); int i = 0; var packType = (from x in packageTypes where x.PackagingTypeID == pack.PackagingTypeID select x).FirstOrDefault(); var exists = (from x in oldPacks where x.BookPackItemOperationID == pack.BookPackItemOperationID select x).FirstOrDefault(); BusinessLogicLayer.Entity.PPM.BookPackingOperation packOperation = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(parentItem.BookPackingOperationID.Value); if (i >= pack.PackageTotal.Value) { break; } if (exists == null || !exists.HasObject) { int bookStart = 0; int bookLast = BookPackItemLogic.GetLastBookSerialForRePackedItem(parentItem.BookPackItemID); if (bookLast == 0) { bookLast = 1; } var oldPackageCount = BookPackItemLogic.GetPackageBooksCount(parentItem.BookPackItemID); int remaining = oldPackageCount; bool isFirst = true; while (remaining > 0) { BusinessLogicLayer.Entity.PPM.BookPackItem item = new BusinessLogicLayer.Entity.PPM.BookPackItem(); item.BookPackingOperationID = packOperation.BookPackingOperationID; item.BookPackItemOperationID = pack.BookPackItemOperationID; item.BookPackItemID = PackID; item.OperationStatusID = 7; item.ParentID = parentRepackID; item.PackSerial = serial; item.ParentBookPackItemID = parentItem.BookPackItemID; string modelCode = ""; List <BusinessLogicLayer.Entity.PPM.BookPackItemModel> itemModels = new List <BusinessLogicLayer.Entity.PPM.BookPackItemModel>(); bookStart = i == 0 ? bookLast : bookLast + 1; bookLast = bookStart + (packType.BooksPerPackage.Value - 1); foreach (BusinessLogicLayer.Entity.PPM.BookPackItemModel examModel in parentItem.ItemModels) { if (packType.ExamModelCount > 1) { BusinessLogicLayer.Entity.PPM.BookPackItemModel newModel = new BusinessLogicLayer.Entity.PPM.BookPackItemModel(); newModel.BookPackItemID = item.BookPackItemID; newModel.ExamModelID = examModel.ExamModelID; modelCode += examModel.ExamModelID + "-"; item.StartBookSerial = bookStart; item.LastBookSerial = bookLast; remaining -= packType.BooksPerPackage.Value; itemModels.Add(newModel); } else { if (isFirst) { remaining = remaining * parentItem.ItemModels.Count; isFirst = false; } itemModels = new List <BusinessLogicLayer.Entity.PPM.BookPackItemModel>(); BusinessLogicLayer.Entity.PPM.BookPackItem itemUnit = new BusinessLogicLayer.Entity.PPM.BookPackItem(); itemUnit.BookPackingOperationID = packOperation.BookPackingOperationID; itemUnit.BookPackItemOperationID = pack.BookPackItemOperationID; itemUnit.BookPackItemID = PackID; itemUnit.OperationStatusID = 7; itemUnit.ParentBookPackItemID = parentItem.BookPackItemID; itemUnit.StartBookSerial = bookStart; itemUnit.LastBookSerial = bookLast; itemUnit.PackSerial = serial; //itemUnit.PackCode = PrintingOperationID + "-" + pack.BookPackingOperationID + "-" + pack.PackagingTypeID + "-" + examModel.ExamModelID + "-" + serial; itemUnit.PackCode = RandomString(12); BusinessLogicLayer.Entity.PPM.BookPackItemModel newModel = new BusinessLogicLayer.Entity.PPM.BookPackItemModel(); newModel.BookPackItemID = item.BookPackItemID; newModel.ExamModelID = examModel.ExamModelID; modelCode += examModel.ExamModelID + "-"; itemModels.Add(newModel); itemUnit.ParentID = parentRepackID; itemUnit.ItemModels = itemModels; remaining -= packType.BooksPerPackage.Value; items.Add(itemUnit); //serial++; } } if (packType.ExamModelCount > 1) { if (!string.IsNullOrEmpty(modelCode)) { modelCode = modelCode.Remove(modelCode.Length - 1, 1); } //item.PackCode = PrintingOperationID + "-" + pack.BookPackingOperationID + "-" + pack.PackagingTypeID + "-" + modelCode + "-" + serial; item.PackCode = RandomString(12); item.ItemModels = itemModels; items.Add(item); } if (parentItem.ItemModels.Count == 0) { remaining = 0; } else { serial++; i++; } ///TODO: Add Pack Items for Sub Packs } } } }
private void AddItemToPack(List <BusinessLogicLayer.Entity.PPM.BookPackItem> items, List <BusinessLogicLayer.Entity.PPM.PackagingType> packageTypes, List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> packing, List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> oldPacks, BusinessLogicLayer.Entity.PPM.BookPrintingOperation model, BusinessLogicLayer.Entity.PPM.Exam exam, ref int count, ref int serial, BusinessLogicLayer.Entity.PPM.BookPackItemOperation pack, BusinessLogicLayer.Entity.PPM.BookPackItem parentItem) { serial = 1; if (parentItem.OperationStatusID != 8) { parentItem.OperationStatusID = 8; parentItem.Save(); } BusinessLogicLayer.Entity.PPM.BookPackingOperation packOperation = new BusinessLogicLayer.Entity.PPM.BookPackingOperation(parentItem.BookPackingOperationID.Value); var packType = (from x in packageTypes where x.PackagingTypeID == pack.PackagingTypeID select x).FirstOrDefault(); var exists = (from x in oldPacks where x.BookPackItemOperationID == pack.BookPackItemOperationID select x).FirstOrDefault(); int bookStart = 0; int bookLast = 0; if (exists == null || !exists.HasObject) { for (int i = 0; i < pack.PackageTotal.Value; i++) { BusinessLogicLayer.Entity.PPM.BookPackItem item = new BusinessLogicLayer.Entity.PPM.BookPackItem(); item.BookPackingOperationID = packOperation.BookPackingOperationID; item.BookPackItemOperationID = pack.BookPackItemOperationID; item.BookPackItemID = PackID; item.OperationStatusID = 7; item.PackSerial = serial; string modelCode = ""; List <BusinessLogicLayer.Entity.PPM.BookPackItemModel> itemModels = new List <BusinessLogicLayer.Entity.PPM.BookPackItemModel>(); bookStart = bookLast + 1; bookLast += bookStart + (i + 1) * packType.BooksPerPackage.Value; bool addModelsToCount = true; foreach (BusinessLogicLayer.Entity.PPM.ExamModelItem examModel in exam.ExamModels) { if (packType.ExamModelCount > 1) { BusinessLogicLayer.Entity.PPM.BookPackItemModel newModel = new BusinessLogicLayer.Entity.PPM.BookPackItemModel(); newModel.BookPackItemID = item.BookPackItemID; newModel.ExamModelID = examModel.ExamModelID; modelCode += examModel.ExamModelID + "-"; item.StartBookSerial = bookStart; item.LastBookSerial = bookLast; itemModels.Add(newModel); } else { itemModels = new List <BusinessLogicLayer.Entity.PPM.BookPackItemModel>(); BusinessLogicLayer.Entity.PPM.BookPackItem itemUnit = new BusinessLogicLayer.Entity.PPM.BookPackItem(); item.BookPackingOperationID = packOperation.BookPackingOperationID; item.BookPackItemOperationID = pack.BookPackItemOperationID; item.BookPackItemID = PackID; itemUnit.OperationStatusID = 7; itemUnit.StartBookSerial = bookStart; itemUnit.LastBookSerial = bookLast; itemUnit.PackSerial = serial; //itemUnit.PackCode = PrintingOperationID + "-" + pack.BookPackingOperationID + "-" + pack.PackagingTypeID + "-" + examModel.ExamModelID + "-" + serial; itemUnit.PackCode = RandomString(12); BusinessLogicLayer.Entity.PPM.BookPackItemModel newModel = new BusinessLogicLayer.Entity.PPM.BookPackItemModel(); newModel.BookPackItemID = item.BookPackItemID; newModel.ExamModelID = examModel.ExamModelID; modelCode += examModel.ExamModelID + "-"; itemModels.Add(newModel); itemUnit.ItemModels = itemModels; items.Add(itemUnit); if (addModelsToCount) { i += exam.ExamModels.Count - 1; addModelsToCount = false; } //serial++; } } if (packType.ExamModelCount > 1) { if (!string.IsNullOrEmpty(modelCode)) { modelCode = modelCode.Remove(modelCode.Length - 1, 1); } //item.PackCode = PrintingOperationID + "-" + pack.BookPackingOperationID + "-" + pack.PackagingTypeID + "-" + modelCode + "-" + serial; item.PackCode = RandomString(12); item.ItemModels = itemModels; items.Add(item); } serial++; ///TODO: Add Pack Items for Sub Packs } } }
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)); }