public ActionResult BookPrintingOperationGridViewPartialDelete(System.Int32 BookPrintingOperationID) { if (BookPrintingOperationID >= 0) { try { BusinessLogicLayer.Components.PPM.BookPrintingOperationLogic logic = new BusinessLogicLayer.Components.PPM.BookPrintingOperationLogic(); if (!logic.HasDependencies(BookPrintingOperationID)) { BusinessLogicLayer.Entity.PPM.BookPrintingOperation type = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(BookPrintingOperationID); if (type.OperationStatusID <= 3 || type.OperationStatusID == 8) { type.Delete(); } else { ViewData["EditError"] = "لا يمكن حذف هذا الطلب يجب ان يكون نوع الطلب طباعة او تحزيم"; } } } catch (Exception e) { ViewData["EditError"] = e.Message; } } var model = new BusinessLogicLayer.Components.PPM.BookPrintingOperationLogic().GetAll(); return(PartialView("_BookPrintingOperationGridViewPartial", model)); }
// GET: BookRePack public ActionResult Index() { BusinessLogicLayer.Entity.PPM.BookPrintingOperation printing = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(); BookPackItemOperationList = new List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation>(); BookRepackPackageItemList = new List <BusinessLogicLayer.Entity.PPM.BookRepackPackageItem>(); return(View(printing)); }
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)); }
// GET: BookPackItemRePack public ActionResult Index() { BusinessLogicLayer.Entity.PPM.BookPrintingOperation printing = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(); BookPackItemOperationList = new List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation>(); BookRepackPackageItemList = new List <BusinessLogicLayer.Entity.PPM.BookRepackPackageItem>(); ViewBag.HasError = false; ViewBag.NotifyMessage = ""; return(View(printing)); }
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 ReceiveOrder(FormCollection form) { var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingOperationID); model.OperationStatusID = 5; model.Save(); model.UpdateItemPackStatus(7); ViewBag.HasError = false; ViewBag.NotifyMessage = Resources.MainResource.ReceivedSuccessfully; ViewBag.IsReceived = model.OperationStatusID != 4; return(View("Receive", 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 PackExam(int ID) { string url = string.Format("{0}/Index/{1}", Url.Action("Index", "BookPackingOperation"), ID); var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(ID); if (model == null) { return(View()); } else { return(Redirect(url)); } }
public ActionResult ReceivePack(int ID) { string url = string.Format("{0}/{1}", Url.Action("Receive", "ReceiveExamPack"), ID); var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(ID); if (model == null) { return(View()); } else { return(Redirect(url)); } }
public ActionResult Receive(int ID = 0) { string url = string.Format("{0}", Url.Action("Index", "ReceiveExamPack")); var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(ID); if (model == null || !model.HasObject) { return(RedirectToAction("Index", "ReceiveExamPack")); } MainID = ID; ViewBag.HasError = false; ViewBag.NotifyMessage = ""; ViewBag.PrintingID = ID; ViewBag.IsReceived = model.OperationStatusID != 4; PrintingOperationID = ID; return(View(model)); }
public ActionResult PrintPacks(int ID = 0, int PrintingID = 0) { string url = string.Format("{0}", Url.Action("Index", "BookPackItemRePack")); var model = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingID); if (model == null || !model.HasObject) { return(RedirectToAction("Index", "BookPackItemRePack")); } RepackID = ID; ViewBag.HasError = false; ViewBag.NotifyMessage = ""; ViewBag.PrintingID = PrintingID; PrintingOperationID = PrintingID; var stream = new MemoryStream(); report.DataSource = new Qiyas.BusinessLogicLayer.Components.PPM.BookPackItemLogic().GetAllByParentID(RepackID); report.ExportToPdf(stream); return(File(stream.GetBuffer(), "application/pdf")); //return View(model); }
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 int TotalPackages(BusinessLogicLayer.Entity.PPM.BookPackItemOperation item) { int total = 0; BusinessLogicLayer.Entity.PPM.PackagingType ptype = new BusinessLogicLayer.Entity.PPM.PackagingType(item.PackagingTypeID.Value); if (ptype == null) { return(0); } BusinessLogicLayer.Entity.PPM.BookPrintingOperation printingOperation = new BusinessLogicLayer.Entity.PPM.BookPrintingOperation(PrintingOperationID); if (printingOperation == null) { return(0); } bool isA3 = ptype.BooksPerPackage == 3 && ptype.ExamModelCount == 1; int totalItems = GetTotalBooksForModel(isA3); int countExams = new BusinessLogicLayer.Components.PPM.ExamLogic().GetExamModelCount(printingOperation.ExamID.Value); if (item.PackingCalculationTypeID == 1) { double t = item.PackingValue.Value / 100.00; total = Convert.ToInt32(Math.Ceiling(totalItems * t)); total = total / (ptype.ExamModelCount.Value * ptype.BooksPerPackage.Value); if (ptype.ExamModelCount == 1) { total = total * countExams; } else { total = total * ptype.ExamModelCount.Value; } } else if (item.PackingCalculationTypeID == 2) { BusinessLogicLayer.Entity.PPM.BookPackItemOperation operation = new BusinessLogicLayer.Entity.PPM.BookPackItemOperation(item.PackingParentID.Value); if (operation == null) { return(0); } totalItems = operation.PackageTotal.Value; if (operation.PackingCalculationTypeID == 1) { double t = item.PackingValue.Value / 100.00; total = Convert.ToInt32(Math.Ceiling(totalItems * t)); total = total / (ptype.ExamModelCount.Value * ptype.BooksPerPackage.Value); if (ptype.ExamModelCount == 1) { total = total * countExams; } else { total = total * ptype.ExamModelCount.Value; } } else if (operation.PackingCalculationTypeID == 2) { BusinessLogicLayer.Entity.PPM.BookPackItemOperation operation2 = new BusinessLogicLayer.Entity.PPM.BookPackItemOperation(operation.PackingParentID.Value); if (operation2 == null) { return(0); } totalItems = operation2.PackageTotal.Value; if (operation2.PackingCalculationTypeID == 1) { double t = item.PackingValue.Value / 100.00; total = Convert.ToInt32(Math.Ceiling(totalItems * t)); } else if (operation2.PackingCalculationTypeID == 3) { total = item.PackingValue.Value; } } else if (operation.PackingCalculationTypeID == 3) { if (ptype.ExamModelCount == 1) { total = item.PackingValue.Value / (ptype.BooksPerPackage.Value * ptype.ExamModelCount.Value); total = total * countExams; } else { total = item.PackingValue.Value / (ptype.BooksPerPackage.Value); //total = total * ptype.ExamModelCount.Value; } } } else if (item.PackingCalculationTypeID == 3) { if (ptype.ExamModelCount == 1) { total = item.PackingValue.Value / (ptype.BooksPerPackage.Value * ptype.ExamModelCount.Value); total = total * countExams; } else { total = item.PackingValue.Value / (ptype.BooksPerPackage.Value); //total = total * ptype.ExamModelCount.Value; } } return(total); }
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 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)); }
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 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)); }