public ActionResult PackageTypeGridViewPartialDelete(System.Int32 PackagingTypeID) { if (PackagingTypeID >= 0) { try { BusinessLogicLayer.Components.PPM.PackagingTypeLogic logic = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic(); if (!logic.HasDependencies(PackagingTypeID)) { Qiyas.BusinessLogicLayer.Entity.PPM.PackagingType package = new BusinessLogicLayer.Entity.PPM.PackagingType(PackagingTypeID); package.Delete(); } else { ViewData["EditError"] = Resources.MainResource.CityHasAssociatedData; } } catch (Exception e) { ViewData["EditError"] = e.Message; } } var model = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetAll(); return(PartialView("_PackageTypeGridViewPartial", model)); }
public ActionResult PackageTypeGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.PPM.PackagingType item) { if (ModelState.IsValid) { try { if (!PackageExists(item.BooksPerPackage.Value, item.ExamModelCount.Value, item.PackagingTypeID)) { Qiyas.BusinessLogicLayer.Entity.PPM.PackagingType package = new BusinessLogicLayer.Entity.PPM.PackagingType(item.PackagingTypeID); package.BooksPerPackage = item.BooksPerPackage; package.ExamModelCount = item.ExamModelCount; package.IsActive = item.IsActive; package.ModifiedDate = DateTime.Now; package.Name = item.Name; package.Total = item.Total; package.Save(); } else { ViewData["EditError"] = Resources.MainResource.PackageTypeExists; } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var model = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetAll(); return(PartialView("_PackageTypeGridViewPartial", model)); }
private bool CheckPackValid() { bool result = true; int count = GetTotalBooksForModel(); int currentPacks = 0; var packageTypes = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetAll(); foreach (var item in BookPackItemOperationList) { var ptype = packageTypes.Where(c => c.PackagingTypeID == item.PackagingTypeID).FirstOrDefault(); currentPacks += item.PackageTotal.Value * ptype.BooksPerPackage.Value; } if (currentPacks != count) { result = false; } foreach (var item in BookRepackPackageItemList) { if (item.PackageTypeExamModelCount == 1) { var tempList = BookRepackPackageItemList.Where(c => c.PackSerial == item.PackSerial); if (tempList.Count() != item.TotalExamModels) { result = false; } } } return(result); }
public List <Qiyas.BusinessLogicLayer.Entity.PPM.BookPackItemOperation> GetPackagingTypeByBookPackID(List <BusinessLogicLayer.Entity.PPM.BookPackItemOperation> list) { var packageTypes = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetAll(); foreach (var item in list) { var ptype = packageTypes.Where(c => c.PackagingTypeID == item.PackagingTypeID).FirstOrDefault(); item.PackagingTypeName = ptype.Name; } return(list); }
private int GetTotalItems() { int result = 0; List <BusinessLogicLayer.Entity.PPM.PackagingType> types = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetAll(); foreach (var item in BookPackItemOperationList) { var type = types.Where(c => c.BooksPerPackage == 3 && c.ExamModelCount == 1).FirstOrDefault(); if (item.PackagingTypeID != type.PackagingTypeID) { result += item.PackageTotal.Value; } } return(result); }
private bool PackageExists(int BookCount, int ExamModelCount, int id) { var currentUser = new BusinessLogicLayer.Entity.PPM.PackagingType(id); var checkUser = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetByBookCountandExamModelCount(BookCount, ExamModelCount); if (checkUser == null) { return(false); } if (!currentUser.HasObject && checkUser != null) { return(true); } else if (currentUser.HasObject && checkUser != null && currentUser.PackagingTypeID != checkUser.PackagingTypeID) { return(true); } return(false); }
public ActionResult PackageTypeGridViewPartial() { var model = new BusinessLogicLayer.Components.PPM.PackagingTypeLogic().GetAll(); return(PartialView("_PackageTypeGridViewPartial", 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 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)); }