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)); }
private bool ExamExists(string name, int id) { var currentUser = new BusinessLogicLayer.Entity.PPM.Exam(id); var checkUser = new BusinessLogicLayer.Components.PPM.ExamLogic().GetByCode(name); if (checkUser == null) { return(false); } if (!currentUser.HasObject && checkUser != null) { return(true); } else if (currentUser.HasObject && checkUser != null && currentUser.ExamID != checkUser.ExamID) { return(true); } return(false); }
private void xrLabelGender_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { XRLabel cell = sender as XRLabel; if (cell == null) { return; } BusinessLogicLayer.Entity.PPM.Exam exCenter = new BusinessLogicLayer.Entity.PPM.Exam(cell.Text); if (exCenter == null) { return; } BusinessLogicLayer.Entity.PPM.StudentGender gender = new BusinessLogicLayer.Entity.PPM.StudentGender(exCenter.StudentGenderID.Value); if (gender == null) { return; } cell.Text = gender.Name; }
public ActionResult ExamGridViewPartialDelete(System.Int32 ExamID) { if (ExamID >= 0) { try { BusinessLogicLayer.Components.PPM.ExamLogic logic = new BusinessLogicLayer.Components.PPM.ExamLogic(); if (!logic.HasDependencies(ExamID)) { BusinessLogicLayer.Entity.PPM.Exam type = new BusinessLogicLayer.Entity.PPM.Exam(ExamID); type.Delete(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } var model = new BusinessLogicLayer.Components.PPM.ExamLogic().GetAllView(); return(PartialView("_ExamGridViewPartial", model)); }
public ActionResult ExamGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.PPM.Exam item) { if (ModelState.IsValid) { try { if (!ExamExists(item.ExamCode, item.ExamID)) { BusinessLogicLayer.Entity.PPM.Exam exam = new BusinessLogicLayer.Entity.PPM.Exam(); exam.ExamCode = item.ExamCode; exam.ExamSpecialityID = item.ExamSpecialityID; exam.ExamTypeID = item.ExamTypeID; exam.Notes = item.Notes; exam.NumberofPages = item.NumberofPages; exam.NumberofSections = item.NumberofSections; exam.StudentGenderID = item.StudentGenderID; exam.TimeForSection = item.TimeForSection; exam.Name = item.Name; exam.ExamTypeID = item.ExamTypeID; exam.IsActive = item.IsActive; exam.ModifiedDate = DateTime.Now; exam.CreatedDate = DateTime.Now; exam.Save(); string[] itemsExamModels = Request["ExamModelCheckBoxList"].Split('|'); var examModels = new BusinessLogicLayer.Components.PPM.ExamModelLogic().GetAll(); for (int i = 1; i < itemsExamModels.Length; i++) { int examModelIndex = 0; if (i == itemsExamModels.Length - 1) { Int32.TryParse(itemsExamModels[i], out examModelIndex); } else { Int32.TryParse(itemsExamModels[i].Remove(itemsExamModels[i].Length - 1, 1), out examModelIndex); } BusinessLogicLayer.Entity.PPM.ExamModelItem mitem = new BusinessLogicLayer.Entity.PPM.ExamModelItem(); mitem.ExamID = exam.ExamID; mitem.ExamModelID = examModels[examModelIndex].ExamModelID; mitem.Save(); } } else { ViewData["EditError"] = Resources.MainResource.ExamExists; } } 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; //ViewData["EditError"] = Resources.MainResource.PleaseCorrectErrors; } var model = new BusinessLogicLayer.Components.PPM.ExamLogic().GetAllView(); return(PartialView("_ExamGridViewPartial", 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 } } } }
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 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)); }
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 } } }