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; }
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); }
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)); }
public ActionResult ExamGridViewPartial() { var model = new BusinessLogicLayer.Components.PPM.ExamLogic().GetAllView(); return(PartialView("_ExamGridViewPartial", 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); }
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)); }