Exemple #1
0
        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);
        }
Exemple #2
0
        public ActionResult BookPackItemOperationGridViewPartialDelete(System.Int32 BookPackItemOperationID)
        {
            if (BookPackItemOperationID >= 0)
            {
                try
                {
                    var item = BookPackItemOperationList.Where(c => c.BookPackItemOperationID == BookPackItemOperationID).FirstOrDefault();
                    BookPackItemOperationList.Remove(item);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            var model = BookPackItemOperationList;

            return(PartialView("_BookPackItemOperationGridViewPartial", model));
        }
Exemple #3
0
        public ActionResult PackingGridViewPartialDelete(System.Int32 BookPackItemOperationID)
        {
            if (BookPackItemOperationID >= 0)
            {
                try
                {
                    var item = BookPackItemOperationList.Where(c => c.BookPackItemOperationID == BookPackItemOperationID).FirstOrDefault();
                    BookPackItemOperationList.Remove(item);
                    //BusinessLogicLayer.Entity.PPM.BookPackItemOperation entity = new BusinessLogicLayer.Entity.PPM.BookPackItemOperation(BookPackItemOperationID);
                    //entity.Delete();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            var model = BookPackItemOperationList;// new BusinessLogicLayer.Components.PPM.BookPackItemOperationLogic().GetByBookPackID(PackID);

            return(PartialView("_RepackGridViewPartial", model));
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        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));
        }