コード例 #1
0
        private IQueryable<TaskExecutor> TaskExecutorList(GridSettings gridSettings)
        {
            //use it in filter
            string codTaskExecutorFilter = string.Empty;
            string taskExecutorNameFilter = string.Empty;
            string formatMaxFilter = string.Empty;

            //if gridsetting is a search option
            if (gridSettings.isSearch)
            {
                //pull search field
                codTaskExecutorFilter = gridSettings.where.rules.Any(r => r.field == "CodExecutor") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "CodExecutor").data : string.Empty;

                taskExecutorNameFilter = gridSettings.where.rules.Any(r => r.field == "TaskExecutorName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TaskExecutorName").data : string.Empty;

                formatMaxFilter = gridSettings.where.rules.Any(r => r.field == "FormatMax") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "FormatMax").data : string.Empty;

            }

            //read all
            var q = taskExecutorRepository.GetAll();

            //execute filter
            if (!string.IsNullOrEmpty(codTaskExecutorFilter))
            {
                q = q.Where(c => c.CodTaskExecutor.ToLower().Contains(codTaskExecutorFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(taskExecutorNameFilter))
            {
                q = q.Where(c => c.TaskExecutorName.ToLower().Contains(taskExecutorNameFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(formatMaxFilter))
            {
                q = q.Where(c => c.FormatMax.ToLower().Contains(formatMaxFilter.ToLower()));
            }

            //if is sorting
            switch (gridSettings.sortColumn)
            {
                case "CodTaskExecutor":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.CodTaskExecutor) : q.OrderBy(c => c.CodTaskExecutor);
                    break;
                case "TaskExecutorName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.TaskExecutorName) : q.OrderBy(c => c.TaskExecutorName);
                    break;
                case "FormatMax":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.FormatMax) : q.OrderBy(c => c.FormatMax);
                    break;
            }

            return q;
        }
コード例 #2
0
        public ActionResult DocumentTaskCenter(GridSettings gridSettings, string codTaskCenter)
        {

            var q = taskCenterRepository.GetDocumentsTaskCenter(codTaskCenter).OrderBy(x => x.IndexOf);
            //            var q = taskCenterRepository.GetDocumentsTaskCenter(codTaskCenter);
            var q3 = q.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize);

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3.ToList()
                    select new
                    {
                        id = a.CodDocumentTaskCenter,
                        cell = new string[] 
                        {                       
                            a.DocumentName,
                            a.CodDocumentTaskCenter,
                            a.FieldA,
                            a.FieldB,
                            a.FieldC,

                            (a.AssignedAt??DateTime.Now).ToString("d"),
                            (a.AlarmStartingAt??DateTime.Now).ToString("d"),  
                          
                            (a.Started??false).ToString(),
                            (a.Started??false)?(a.StartedAt??DateTime.Now).ToString("d"):"",
                            (a.Started??false)?(a.AlarmFinishingAt??DateTime.Now).ToString("d"):"",

                            (a.Finished??false).ToString(),

                            //used to color
                            //yellow --> to start today
                            ((a.Started??false)?false:(a.AlarmStartingAt??DateTime.Now).ToString("d")==DateTime.Now.ToString("d")).ToString(),                            
                            //red!!!
                            ((a.Started??false)?false:(a.AlarmStartingAt??DateTime.Now)<DateTime.Now).ToString(),
                            //yellow
                            (((a.Finished??false)?false:(a.AlarmFinishingAt??DateTime.Now).ToString("d")==DateTime.Now.ToString("d"))&&(a.Started??false)).ToString(),
                            //red
                            (((a.Finished??false)?false:(a.AlarmFinishingAt??DateTime.Now)<DateTime.Now)&&(a.Started??false)).ToString(),

                            (a.Finished??false).ToString(),
                            (a.Started??false).ToString(),

                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);

        }
コード例 #3
0
ファイル: ProductController_Ex.cs プロジェクト: algola/backup
        public ActionResult ProductList(GridSettings gridSettings)
        {
            string codProductFilter = string.Empty;
            string productNameFilter = string.Empty;
            string typeOfProductFilter = string.Empty;
            string warehouseName = string.Empty;
            //read from validation's language file

            //LANGFILE
            var resman = new System.Resources.ResourceManager(typeof(Strings).FullName, typeof(Strings).Assembly);
            string bookSheetType = resman.GetString("ProductBookSingleSheetType");
            string singleSheetType = resman.GetString("ProductSingleSheetType");
            string blockSheetType = resman.GetString("ProductBlockSheetType");

            if (gridSettings.isSearch)
            {
                codProductFilter = gridSettings.where.rules.Any(r => r.field == "CodProduct") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "CodProduct").data : string.Empty;

                productNameFilter = gridSettings.where.rules.Any(r => r.field == "ProductName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "ProductName").data : string.Empty;

                typeOfProductFilter = gridSettings.where.rules.Any(r => r.field == "TypeOfProduct") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TypeOfProduct").data : string.Empty;

                warehouseName = gridSettings.where.rules.Any(r => r.field == "WarehouseName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "WarehouseName").data : string.Empty;

            }


            var fff = productRepository.GetAll().ToArray();

            var q = warehouseRepository.GetAll();

            if (!string.IsNullOrEmpty(codProductFilter))
            {
                q = q.Where(c => c.CodProduct.ToLower().Contains(codProductFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(productNameFilter))
            {
                q = q.Where(c => c.Product.ProductName.ToLower().Contains(productNameFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(warehouseName))
            {
                q = q.Where(c => c.WarehouseSpec.WarehouseName.ToLower().Contains(warehouseName.ToLower()));
            }


            switch (gridSettings.sortColumn)
            {
                case "CodProduct":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.CodProduct) : q.OrderBy(c => c.CodProduct);
                    break;
                case "ProductName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.Product.ProductName) : q.OrderBy(c => c.Product.ProductName);
                    break;
                case "WarehouseName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.WarehouseSpec.WarehouseName) : q.OrderBy(c => c.WarehouseSpec.WarehouseName);
                    break;
            }

            var q2 = q.ToList();

            var pp = q2.OfType<WarehouseProduct>();

            var q3 = pp.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            long startRow = (pageIndex - 1) * pageSize;
            long endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodProduct,
                        cell = new string[] 
                        {                       
                            a.CodProduct,
                            a.CodProduct,
                            a.CodProduct,
                            a.WarehouseSpec!=null?a.WarehouseSpec.WarehouseName:"",
                            a.Product!=null?a.Product.ProductName:"",
                            ((a.QuantityOnHand??0) < (a.MinQuantity??0))?"Sotto Scorta":"",
                            a.QuantityOnHand==null?"0":a.QuantityOnHand.ToString()
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #4
0
        public ActionResult CustomerSupplierList(GridSettings gridSettings, bool onlyCustomer)
        {
            string codCustomerSupplierFilter = string.Empty;
            string businessNameFilter = string.Empty;
            string vatNumberFilter = string.Empty;
            string taxCodeFilter = string.Empty;

            string typeOfCustomerSupplierFilter = string.Empty;

            //read from validation's language file
            //this resource has to be the same as view's resource
            var resman = new System.Resources.ResourceManager(typeof(Strings).FullName, typeof(Strings).Assembly);
            string customerType = resman.GetString("CustomerType");
            string supplierType = resman.GetString("SupplierType");

            if (gridSettings.isSearch)
            {
                codCustomerSupplierFilter = gridSettings.where.rules.Any(r => r.field == "CodCustomerSupplier") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "CodCustomerSupplier").data : string.Empty;

                businessNameFilter = gridSettings.where.rules.Any(r => r.field == "BusinessName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "BusinessName").data : string.Empty;
                
                vatNumberFilter = gridSettings.where.rules.Any(r => r.field == "VatNumber") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "VatNumber").data : string.Empty;
                
                taxCodeFilter = gridSettings.where.rules.Any(r => r.field == "TaxCode") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TaxCode").data : string.Empty;

                typeOfCustomerSupplierFilter = gridSettings.where.rules.Any(r => r.field == "TypeOfCustomerSupplier") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TypeOfCustomerSupplier").data : string.Empty;
        
            }
            var q = customerSupplierRepository.GetAll();

            if (onlyCustomer)
            {
                q = q.OfType<Customer>();
            }

            if (!string.IsNullOrEmpty(codCustomerSupplierFilter))
            {
                q = q.Where(c => c.CodCustomerSupplier.ToLower().Contains(codCustomerSupplierFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(businessNameFilter))
            {
                q = q.Where(c => c.BusinessName.ToLower().Contains(businessNameFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(vatNumberFilter))
            {
                q = q.Where(c => c.VatNumber.ToLower().Contains(vatNumberFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(taxCodeFilter))
            {
                q = q.Where(c => c.TaxCode.ToLower().Contains(taxCodeFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(typeOfCustomerSupplierFilter))
            {
                Boolean isCust = false, isSupp = false;

                //to match with language we have to compare filter with resource
                isCust = (customerType.ToLower().Contains(typeOfCustomerSupplierFilter.ToLower()));
                isSupp = (supplierType.ToLower().Contains(typeOfCustomerSupplierFilter.ToLower()));

                var a = isCust ? (IQueryable<PapiroMVC.Models.CustomerSupplier>)q.OfType<PapiroMVC.Models.Customer>() : customerSupplierRepository.FindBy(x => x.CodCustomerSupplier == "");
                var b = isSupp ? (IQueryable<PapiroMVC.Models.CustomerSupplier>)q.OfType<PapiroMVC.Models.Supplier>() : customerSupplierRepository.FindBy(x => x.CodCustomerSupplier == "");

                var res = (a.Union(b));
                q = (IQueryable<PapiroMVC.Models.CustomerSupplier>)res;
            }

            switch (gridSettings.sortColumn)
            {
                case "CodCustomerSupplier":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.CodCustomerSupplier) : q.OrderBy(c => c.CodCustomerSupplier);
                    break;
                case "BusinessName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.BusinessName) : q.OrderBy(c => c.BusinessName);
                    break;
                case "VatNumber":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.VatNumber) : q.OrderBy(c => c.VatNumber);
                    break;
                case "TaxCode":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.TaxCode) : q.OrderBy(c => c.TaxCode);
                    break;
            }

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();
            
            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodCustomerSupplier,
                        cell = new string[] 
                        {                       
                            a.CodCustomerSupplier,
                            a.CodCustomerSupplier,
                            a.TypeOfCustomerSupplier.ToString(),
                            a.BusinessName, 
                            a.VatNumber, 
                            a.TaxCode, 
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #5
0
        public ActionResult DocumentProductQuantitiesList(string CodDocument, string CodProduct, GridSettings gridSettings)
        {
            var q = documentRepository.GetSingle(CodDocument).DocumentProducts.Where(x => x.CodProduct == CodProduct);

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodDocumentProduct,
                        cell = new string[] 
                        {                       
                            a.CodDocumentProduct,
                            a.CodProduct,      
                            a.Quantity.ToString(),
                            (a.Markup??0).ToString(),
                            a.UnitPrice??"0",
                            a.TotalAmount??"0"
                        }
                    }
                ).Distinct().ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #6
0
        /// <summary>
        /// List of DocumentProduct in a Document ie. Estimate
        /// </summary>
        /// <param name="CodDocument"></param>
        /// <param name="gridSettings"></param>
        /// <returns></returns>
        public ActionResult DocumentProductListInDocument(string CodDocument, GridSettings gridSettings)
        {

            if (CodDocument != null)
            {
                var q = documentRepository.GetSingle(CodDocument).DocumentProducts;

                foreach (var i in q)
                {
                    i.Product = productRepository.GetSingle(i.CodProduct);
                }

                var q2 = q.Select((p) => new { CodProduct = p.CodProduct, ProductName = p.ProductName, ProductRefName = p.Product.ProductRefName }).Distinct();

                //var q2 = q.ToList();
                var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

                int totalRecords = q.Count();

                // create json data
                int pageIndex = gridSettings.pageIndex;
                int pageSize = gridSettings.pageSize;

                int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

                int startRow = (pageIndex - 1) * pageSize;
                int endRow = startRow + pageSize;

                var jsonData = new
                {
                    total = totalPages,
                    page = pageIndex,
                    records = totalRecords,
                    rows =
                    (
                        from a in q3
                        select new
                        {
                            id = a.CodProduct,
                            cell = new string[] 
                            {
                                a.CodProduct,
                                a.CodProduct,
                                a.CodProduct,
                                a.ProductRefName,
                                a.ProductName   //attributo derivato
                            }
                        }
                    ).ToArray()
                };

                return Json(jsonData, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(null, JsonRequestBehavior.AllowGet);
            }
        }
コード例 #7
0
        public ActionResult EstimateList(GridSettings gridSettings)
        {

            var q = this.DocumentList(gridSettings).OfType<Estimate>();

            var q3 = q.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize);

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3.ToList()
                    select new
                    {
                        id = a.CodDocument,
                        cell = new string[] 
                        {                       
                            a.CodDocument,
                            a.Customer,
                            a.EstimateNumberSerie + "/" + a.EstimateNumber + "%" + a.CodDocument,
                            (a.DateDocument??DateTime.Now).ToString("d"),
                            a.DocumentName,
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);


        }
コード例 #8
0
        public ActionResult ProductPartSerigraphyOptionList(GridSettings gridSettings, string codProductPartTask)
        {

            var q2 = productRepository.GetProductPartTaskOptions(codProductPartTask).OrderBy(x => x.CodProductPartTaskOption);
            var q = q2.OfType<ProductPartSerigraphyOption>();
            var q3 = q.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize);

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3.ToList()
                    select new
                    {
                        id = a.CodProductPartTaskOption,
                        cell = new string[] 
                        {                       
                            a.CodProductPartTaskOption,
                            a.TypeOfTaskSerigraphy,
                            a.InkSerigraphy,
                            a.Overlay.ToString()
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);

        }
コード例 #9
0
        public ActionResult FlatRollList(GridSettings gridSettings)
        {
            //common serarch and order
            //            var q = this.LithoList(gridSettings).OfType<LithoSheet>();

            var q = this.TaskExecutorList(gridSettings).OfType<FlatRoll>();

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodTaskExecutor,
                        cell = new string[] 
                        {                                
                            a.SetTaskExecutorEstimatedOn.Count()==0?"CostError":
                                a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnMq?"CostMq":
                                    a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.RollEstimatedOnTime?"CostTime":
                                        a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnRun?"CostRun":"",                                           
                            a.CodTaskExecutor,
                            a.CodTaskExecutor,
                            a.TypeOfExecutor.ToString(),
                            a.TaskExecutorName,
                            a.PrintingUnit.ToString(),
//                            (a.Width??Convert.ToDouble(0)).ToString(CultureInfo.InvariantCulture.NumberFormat)
                        }

                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);

        }
コード例 #10
0
        private IQueryable<Digital> DigitalList(GridSettings gridSettings)
        {
            //common serarch and order
            var q = this.TaskExecutorList(gridSettings).OfType<Digital>();

            //use it in filter
            string bwSide1Filter = string.Empty;
            string bwSide2Filter = string.Empty;
            string colorSide1Filter = string.Empty;
            string colorSide2Filter = string.Empty;

            //if gridsetting is a search option
            if (gridSettings.isSearch)
            {
                //pull search field
                bwSide1Filter = gridSettings.where.rules.Any(r => r.field == "BWSide1") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "BWSide1").data : string.Empty;

                bwSide2Filter = gridSettings.where.rules.Any(r => r.field == "BWSide2") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "BWSide2").data : string.Empty;

                colorSide1Filter = gridSettings.where.rules.Any(r => r.field == "ColorSide1") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "ColorSide1").data : string.Empty;

                colorSide2Filter = gridSettings.where.rules.Any(r => r.field == "ColorSide2") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "ColorSide2").data : string.Empty;

            }

            //execute filter
            if (!string.IsNullOrEmpty(bwSide1Filter))
            {
                try
                {
                    var bwSide1Bool = Convert.ToBoolean(bwSide1Filter);
                    q = q.Where(c => c.BWSide1 == bwSide1Bool);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (!string.IsNullOrEmpty(bwSide2Filter))
            {
                try
                {
                    var bwSide2Bool = Convert.ToBoolean(bwSide2Filter);
                    q = q.Where(c => c.BWSide2 == bwSide2Bool);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (!string.IsNullOrEmpty(colorSide1Filter))
            {
                try
                {
                    var colorSide1Bool = Convert.ToBoolean(colorSide1Filter);
                    q = q.Where(c => c.ColorSide1 == colorSide1Bool);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (!string.IsNullOrEmpty(colorSide2Filter))
            {
                try
                {
                    var colorSide2Bool = Convert.ToBoolean(colorSide2Filter);
                    q = q.Where(c => c.ColorSide2 == colorSide2Bool);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            //if is sorting
            switch (gridSettings.sortColumn)
            {
                case "BWSide1":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.BWSide1) : q.OrderBy(c => c.BWSide1);
                    break;
                case "BWSide2":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.BWSide2) : q.OrderBy(c => c.BWSide2);
                    break;
                case "ColorSide1":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.ColorSide1) : q.OrderBy(c => c.ColorSide1);
                    break;
                case "ColorSide2":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.ColorSide2) : q.OrderBy(c => c.ColorSide2);
                    break;

            }

            return q;
        }
コード例 #11
0
        private IQueryable<Litho> LithoList(GridSettings gridSettings)
        {
            //common serarch and order
            var qqqq = this.TaskExecutorList(gridSettings).OfType<LithoSheet>();
            var qq = this.TaskExecutorList(gridSettings).OfType<LithoRoll>();

            var q = qq.Union((IQueryable<Litho>)qqqq);

            //use it in filter
            string printingUnitFilter = string.Empty;
            string sheetwiseAfterPrintingUnitFilter = string.Empty;

            //if gridsetting is a search option
            if (gridSettings.isSearch)
            {
                //pull search field
                printingUnitFilter = gridSettings.where.rules.Any(r => r.field == "PrintingUnit") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "PrintingUnit").data : string.Empty;

                sheetwiseAfterPrintingUnitFilter = gridSettings.where.rules.Any(r => r.field == "SheetwiseAfterPrintingUnit") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "SheetwiseAfterPrintingUnit").data : string.Empty;

            }

            //execute filter
            if (!string.IsNullOrEmpty(printingUnitFilter))
            {
                try
                {
                    var printingUnitShort = Convert.ToInt16(printingUnitFilter);
                    q = q.Where(c => c.PrintingUnit == printingUnitShort);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

            }

            if (!string.IsNullOrEmpty(sheetwiseAfterPrintingUnitFilter))
            {
                try
                {
                    var sheetwiseAfterPrintingUnitLong = Convert.ToInt64(sheetwiseAfterPrintingUnitFilter);
                    q = q.Where(c => c.SheetwiseAfterPrintingUnit == sheetwiseAfterPrintingUnitLong);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            //if is sorting
            switch (gridSettings.sortColumn)
            {
                case "PrintingUnit":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.PrintingUnit) : q.OrderBy(c => c.PrintingUnit);
                    break;
                case "SheetwiseAfterPrintingUnit":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.SheetwiseAfterPrintingUnit) : q.OrderBy(c => c.SheetwiseAfterPrintingUnit);
                    break;
            }

            return q;
        }
コード例 #12
0
        /// <summary>
        /// Elenco delle macchine da stampa divise per tipo di lavorazione che possono effettuare!!!!
        /// </summary>
        /// <param name="gridSettings"></param>
        /// <param name="codTypeOfTask"></param>
        /// <returns></returns>
        public ActionResult TaskExecutors(GridSettings gridSettings, string codTypeOfTask)
        {
            //load taskexecutor
            var lst = TaskExecutorList(gridSettings);
            //and filtering on codTypeOfTask
            var q = TaskExecutor.FilterByTask(lst, codTypeOfTask);

            string typeOfTaskExecutorFilter = string.Empty;
            //if gridsetting is a search option

            //read from validation's language file
            //this resource has to be the same as view's resource
            var resman = new System.Resources.ResourceManager(typeof(Strings).FullName, typeof(Strings).Assembly);
            string sheetType = resman.GetString("SheetType");
            string rollType = resman.GetString("RollType");
            string plotterSheetType = resman.GetString("PlotterSheetType");
            string plotterRollType = resman.GetString("PlotterRollType");
            string ctrlTblType = resman.GetString("ControlTableRollType");
            string flexoType = resman.GetString("FlexoType");
            string flatRollType = resman.GetString("FlatRollType");
            string prePostPressType = resman.GetString("PrePostPressType");

            if (gridSettings.isSearch)
            {
                typeOfTaskExecutorFilter = gridSettings.where.rules.Any(r => r.field == "TypeOfTaskExecutor") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TypeOfTaskExecutor").data : string.Empty;
            }

            if (!string.IsNullOrEmpty(typeOfTaskExecutorFilter))
            {
                Boolean isSheet = false,
                    isRoll = false,
                    isPlotterS = false,
                    isPlotterR,
                    isCrtlTab = false,
                    isFlexo = false,
                    isFlatRoll = false,
                    isPrePostPress = false;

                //to match with language we have to compare filter with resource
                isSheet = (sheetType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));
                isRoll = (rollType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));
                isPlotterS = (plotterSheetType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));
                isPlotterR = (plotterRollType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));
                isFlexo = (flexoType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));
                isCrtlTab = (ctrlTblType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));
                isFlatRoll = (flatRollType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));

                isPrePostPress = (prePostPressType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));


                var s1 = isSheet ? (IQueryable<TaskExecutor>)q.OfType<LithoSheet>() : q.Where(x => x.CodTaskExecutor == "");
                var s2 = isSheet ? (IQueryable<TaskExecutor>)q.OfType<DigitalSheet>() : q.Where(x => x.CodTaskExecutor == "");

                var r1 = isRoll ? (IQueryable<TaskExecutor>)q.OfType<LithoRoll>() : q.Where(x => x.CodTaskExecutor == "");
                var r2 = isRoll ? (IQueryable<TaskExecutor>)q.OfType<DigitalRoll>() : q.Where(x => x.CodTaskExecutor == "");

                var p1 = isPlotterS ? (IQueryable<TaskExecutor>)q.OfType<PlotterSheet>() : q.Where(x => x.CodTaskExecutor == "");
                var p2 = isPlotterR ? (IQueryable<TaskExecutor>)q.OfType<PlotterRoll>() : q.Where(x => x.CodTaskExecutor == "");

                var g1 = isPrePostPress ? (IQueryable<TaskExecutor>)q.OfType<PrePostPress>() : q.Where(x => x.CodTaskExecutor == "");

                var res = ((((((s1.Union(s2)).Union(r1)).Union(r2)).Union(p1)).Union(p2)).Union(g1));
                q = (IQueryable<PapiroMVC.Models.TaskExecutor>)res;
            }

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodTaskExecutor,
                        cell = new string[]
                        {
                            a.SetTaskExecutorEstimatedOn.Count()==0?"CostError":
                                a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnMq?"CostMq":
                                    a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnTime?"CostTime":
                                        a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnRun?"CostRun":
                                            a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.RollEstimatedOnTime?"CostTime":
                                                a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.FlatRollEstimatedOnTime?"CostTime":
                                                    a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.PlotterOnMq?"CostMq":
                                                        a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.DigitalOnTime?"CostTime":
                                                            a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.DigitalOnRun?"CostRun":
                                                                a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.ControlTableRollEstimatedOnTime?"CostTime":"",
                            a.CodTaskExecutor,
                            a.CodTaskExecutor,
                            a.TypeOfExecutor.ToString(),
                            a.TaskExecutorName,
                            a.TypeOfTask!=null?a.TypeOfTask.TaskName:"",
                            a.TaskExecutorSecondName,
                            a.SetTaskExecutorEstimatedOn.Count()==0?"":a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn.ToString()
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);




        }
コード例 #13
0
ファイル: ProductController_Ex.cs プロジェクト: algola/backup
        public ActionResult ProductNameGeneratorList(GridSettings gridSettings)
        {
            //read from validation's language file


            var q = productRepository.GetAllProductNameGenerator();
            var q3 = q.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodMenuProduct,
                        cell = new string[] 
                        {                       
                            a.CodMenuProduct,
                            a.CodMenuProduct,
                            a.Generator
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #14
0
        public ActionResult Costs(GridSettings gridSettings, String codDocumentProduct)
        {
            var q = documentRepository.GetCostsByCodDocumentProduct(codDocumentProduct).Where(x => !(x.Hidden ?? false));

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodCost,
                        cell = new string[] 
                        {                       
                            a.CodCost,
                            a.CodDocumentProduct,
                            (a.Locked??false).ToString(),
                            (a.TypeOfCalcolous??0).ToString(), //0=incluso, 1=Aux, 2=escluso
                            a.Description,
                            (a.CostDetails.FirstOrDefault()!=null?a.CostDetails.FirstOrDefault().TypeOfQuantity??0:5).ToString(),
                            (a.Quantity??0).ToString(),                            
                            a.UnitCost,
                            a.TotalCost,
                            (a.Markup??0).ToString(),
                            a.GranTotalCost
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #15
0
        public ActionResult DigitalSheetListAndRoll(GridSettings gridSettings)
        {
            //common serarch and order
            // var q = this.DigitalList(gridSettings).OfType<DigitalSheet>();
            var q = this.DigitalList(gridSettings);

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodTaskExecutor,
                        cell = new string[] 
                        {     
                            a.SetTaskExecutorEstimatedOn.Count()==0?"CostError":
                                a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnMq?"CostMq":
                                    a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnTime?"CostTime":
                                        a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnRun?"CostRun":                                           
                                            a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.DigitalOnTime?"CostTime":                                           
                                                a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.DigitalOnRun?"CostRun":"",                                           
                            a.CodTaskExecutor,
                            a.CodTaskExecutor,
                            a.TypeOfExecutor.ToString(),
                            a.TaskExecutorName,
                            a.FormatMax,
                            a.BWSide1.ToString(),
                            a.BWSide2.ToString(),
                            a.ColorSide1.ToString(),
                            a.ColorSide2.ToString(),
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);

        }
コード例 #16
0
        /// <summary>
        /// List of all DocumentProducts
        /// </summary>
        /// <param name="gridSettings"></param>
        /// <returns></returns>
        public ActionResult ProductsList(GridSettings gridSettings)
        {
            string codProductFilter = string.Empty;
            string productRefNameFilter = string.Empty;
            string productNameFilter = string.Empty;

            if (gridSettings.isSearch)
            {
                codProductFilter = gridSettings.where.rules.Any(r => r.field == "CodProduct") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "CodProduct").data : string.Empty;

                productNameFilter = gridSettings.where.rules.Any(r => r.field == "ProductName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "ProductName").data : string.Empty;

                productRefNameFilter = gridSettings.where.rules.Any(r => r.field == "ProductRefName") ?
                   gridSettings.where.rules.FirstOrDefault(r => r.field == "ProductRefName").data : string.Empty;

            }

            var q = documentRepository.GetAllProducts().OrderByDescending(x => x.TimeStampTable).AsQueryable();

            if (!string.IsNullOrEmpty(codProductFilter))
            {
                q = q.Where(c => c.CodProduct != null && c.CodProduct.ToLower().Contains(codProductFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(productNameFilter))
            {
                q = q.Where(c => c.ProductName != null && c.ProductName.ToLower().Contains(productNameFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(productRefNameFilter))
            {
                q = q.Where(c => (c.ProductRefName != null && c.ProductRefName.ToLower().Contains(productRefNameFilter.ToLower())) ||
                    (c.ProductRefName != null && c.ProductRefName.ToLower().Contains(productRefNameFilter.ToLower())));
            }



            switch (gridSettings.sortColumn)
            {
                case "CodProduct":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.CodProduct) : q.OrderBy(c => c.CodProduct);
                    break;
                case "ProductName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.ProductName) : q.OrderBy(c => c.ProductName);
                    break;
                case "ProductRefName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.ProductRefName) : q.OrderBy(c => c.ProductRefName);
                    break;
            }

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodProduct,
                        cell = new string[] 
                            {      
                                a.CodProduct,
                                a.CodProduct,
                                a.ProductName,
                                a.ProductRefName  //attributo derivato
                            }
                    }
                ).ToArray()
            };
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #17
0
 public IQueryable<Plotter> PlotterList(GridSettings gridSettings)
 {
     //common serarch and order
     var q = this.TaskExecutorList(gridSettings).OfType<Plotter>();
     return q;
 }
コード例 #18
0
        private IQueryable<Document> DocumentList(GridSettings gridSettings)
        {
            string customerFilter = string.Empty;
            string serialFilter = string.Empty;
            string codDocumentFilter = string.Empty;
            string documentNameFilter = string.Empty;
            string dateDocumentFilter = string.Empty;


            string categoryFilter = string.Empty;

            if (gridSettings.isSearch)
            {

                categoryFilter = gridSettings.where.rules.Any(r => r.field == "Category") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "Category").data : string.Empty;

                customerFilter = gridSettings.where.rules.Any(r => r.field == "Customer") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "Customer").data : string.Empty;

                serialFilter = gridSettings.where.rules.Any(r => r.field == "EstimateNumberSerie") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "EstimateNumberSerie").data : string.Empty;

                codDocumentFilter = gridSettings.where.rules.Any(r => r.field == "CodDocument") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "CodDocument").data : string.Empty;

                dateDocumentFilter = gridSettings.where.rules.Any(r => r.field == "DateDocument") ?
                   gridSettings.where.rules.FirstOrDefault(r => r.field == "DateDocument").data : string.Empty;

                documentNameFilter = gridSettings.where.rules.Any(r => r.field == "DocumentName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "DocumentName").data : string.Empty;

            }

            var q = documentRepository.GetAll();

            ////read from validation's language file
            ////this resource has to be the same as view's resource
            //var resman = new System.Resources.ResourceManager(typeof(Strings).FullName, typeof(Strings).Assembly);
            //string customerType = resman.GetString("CustomerType");
            //string supplierType = resman.GetString("SupplierType");

            //sarebbe da tradurre da StateName a codState!!!!
            if (!string.IsNullOrEmpty(categoryFilter))
            {
                q = q.Where(c => c.DocumentStates.Where(y => y.CodState == categoryFilter && y.Selected).Count() > 0);
            }


            if (!string.IsNullOrEmpty(customerFilter))
            {
                q = q.Where(c => c.Customer != null && c.Customer.ToLower().Contains(customerFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(serialFilter))
            {
                q = q.Where(c => (c.EstimateNumberSerie != null && c.EstimateNumberSerie.ToLower().Contains(serialFilter.ToLower())) ||
                    (c.EstimateNumber != null && c.EstimateNumber.ToLower().Contains(serialFilter.ToLower())) ||
                    (c.CodDocument != null && c.EstimateNumber != null && (c.EstimateNumberSerie + "/" + c.EstimateNumber).ToLower().Contains(serialFilter.ToLower())));
            }

            if (!string.IsNullOrEmpty(codDocumentFilter))
            {
                q = q.Where(c => c.CodDocument.ToLower().Contains(codDocumentFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(dateDocumentFilter))
            {
                try
                {
                    DateTime dt = Convert.ToDateTime(dateDocumentFilter);
                    q = q.Where(c => (c.DateDocument ?? DateTime.Now).Year == dt.Year && (c.DateDocument ?? DateTime.Now).Month == dt.Month && (c.DateDocument ?? DateTime.Now).Day == dt.Day);

                }
                catch (Exception)
                {

                }
            }

            if (!string.IsNullOrEmpty(documentNameFilter))
            {
                q = q.Where(c => c.DocumentName != null && c.DocumentName.ToLower().Contains(documentNameFilter.ToLower()));
            }



            switch (gridSettings.sortColumn)
            {
                case "Customer":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.Customer) : q.OrderBy(c => c.Customer);
                    break;
                case "CodDocument":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.CodDocument) : q.OrderBy(c => c.CodDocument);
                    break;

                case "DateDocument":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.DateDocument) : q.OrderBy(c => c.DateDocument);
                    break;
                case "DocumentName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.DocumentName) : q.OrderBy(c => c.DocumentName);
                    break;
                default:
                    q = q.OrderByDescending(c => c.CodDocument);
                    break;
            }
            return q;
        }
コード例 #19
0
        public ActionResult PrePostPressList(GridSettings gridSettings)
        {
            //common serarch and order
            var q = this.TaskExecutorList(gridSettings).OfType<PrePostPress>();


            string typeOfTaskExecutorFilter = string.Empty;
            //if gridsetting is a search option

            //read from validation's language file
            //this resource has to be the same as view's resource
            var resman = new System.Resources.ResourceManager(typeof(Strings).FullName, typeof(Strings).Assembly);
            string ctrlTblType = resman.GetString("ControlTableRollType");
            // string rollType = resman.GetString("PlotterRollType");


            if (gridSettings.isSearch)
            {
                typeOfTaskExecutorFilter = gridSettings.where.rules.Any(r => r.field == "TypeOfTaskExecutor") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TypeOfTaskExecutor").data : string.Empty;
            }

            if (!string.IsNullOrEmpty(typeOfTaskExecutorFilter))
            {
                Boolean isTable = false, isSupp = false;

                //to match with language we have to compare filter with resource
                isTable = (ctrlTblType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));
                //                isSupp = (rollType.ToLower().Contains(typeOfTaskExecutorFilter.ToLower()));

                var a = isTable ? (IQueryable<PrePostPress>)q.OfType<ControlTableRoll>() : q.Where(x => x.CodTaskExecutor == "");
                //                var b = isSupp ? (IQueryable<Plotter>)q.OfType<PlotterRoll>() : q.Where(x => x.CodTaskExecutor == "");

                //                var res = (a.Union(b));
                //                q = (IQueryable<Plotter>)res;

                q = a;
            }


            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodTaskExecutor,
                        cell = new string[] 
                        {     
                            a.SetTaskExecutorEstimatedOn.Count()==0?"CostError":
                                a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnMq?"CostMq":
                                    a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnTime?"CostTime":
                                        a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.OnRun?"CostRun":
                                            a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.BindingOnTime?"CostTime":
                                                a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.BindingOnRun?"CostRun":
                                                    a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.RollEstimatedOnTime?"CostTime":                                                                                               
                                                        a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.DigitalOnTime?"CostTime":                                           
                                                            a.SetTaskExecutorEstimatedOn.FirstOrDefault().TypeOfEstimatedOn==TaskEstimatedOn.EstimatedOnType.DigitalOnRun?"CostRun":"",                                           

                            a.CodTaskExecutor,
                            a.CodTaskExecutor,
//CODTASKTODO   a.CodTask,
                            a.TaskExecutorName,
                            a.TypeOfExecutor.ToString()
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);

        }
コード例 #20
0
        public ActionResult OrderList(GridSettings gridSettings)
        {

            var q = this.DocumentList(gridSettings).OfType<Order>();
            var q3 = q.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize);

            int totalRecords = q.Count();
            string orderNumberFilter = string.Empty;

            if (gridSettings.isSearch)
            {
                orderNumberFilter = gridSettings.where.rules.Any(r => r.field == "OrderNumberSerie") ?
                      gridSettings.where.rules.FirstOrDefault(r => r.field == "OrderNumberSerie").data : string.Empty;

            }

            if (!string.IsNullOrEmpty(orderNumberFilter))
            {
                q = q.Where(c => c.DocumentName != null && c.DocumentName.ToLower().Contains(orderNumberFilter.ToLower()));
            }
            switch (gridSettings.sortColumn)
            {
                case "OrderNumberSerie":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.OrderNumberSerie) : q.OrderBy(c => c.OrderNumberSerie);
                    break;
                default:
                    q = q.OrderByDescending(c => c.CodDocument);
                    break;
            }



            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3.ToList()
                    select new
                    {
                        id = a.CodDocument,
                        cell = new string[] 
                        {                       
                            a.CodDocument,
                            a.OrderNumberSerie + "/" + a.OrderNumber,
                            a.Customer,
                            a.OrderProduct.Document.EstimateNumberSerie + "/" + a.OrderProduct.Document.EstimateNumber + "%" + a.OrderProduct.CodDocument,
                            a.DocumentName,
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);


        }
コード例 #21
0
 private IQueryable<Step> StepsList(string codTaskExecutorOn, GridSettings gridSettings)
 {
     //read all
     var z = taskExecutorRepository.GetSingleEstimatedOn(codTaskExecutorOn);
     var z2 = z.steps;
     return z2.OrderBy(x => x.Format, new EmptyStringsAreLast()).ThenBy(x => x.FromUnit).AsQueryable();
 }
コード例 #22
0
        /// <summary>
        /// List of all DocumentProducts
        /// </summary>
        /// <param name="gridSettings"></param>
        /// <returns></returns>
        public ActionResult DocumentProductsList(GridSettings gridSettings)
        {
            string codProductFilter = string.Empty;
            string serialFilter = string.Empty;
            string documentAndProductRefNameFilter = string.Empty;
            string productNameFilter = string.Empty;
            string quantityFilter = string.Empty;
            string unitPriceFilter = string.Empty;
            string totalAmountFilter = string.Empty;
            string markupFilter = string.Empty;


            if (gridSettings.isSearch)
            {
                codProductFilter = gridSettings.where.rules.Any(r => r.field == "CodProduct") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "CodProduct").data : string.Empty;

                serialFilter = gridSettings.where.rules.Any(r => r.field == "EstimateNumberSerie") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "EstimateNumberSerie").data : string.Empty;

                productNameFilter = gridSettings.where.rules.Any(r => r.field == "ProductName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "ProductName").data : string.Empty;

                documentAndProductRefNameFilter = gridSettings.where.rules.Any(r => r.field == "DocumentAndProductRefName") ?
                   gridSettings.where.rules.FirstOrDefault(r => r.field == "DocumentAndProductRefName").data : string.Empty;

                quantityFilter = gridSettings.where.rules.Any(r => r.field == "Quantity") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "Quantity").data : string.Empty;

                unitPriceFilter = gridSettings.where.rules.Any(r => r.field == "UnitPrice") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "UnitPrice").data : string.Empty;

                totalAmountFilter = gridSettings.where.rules.Any(r => r.field == "TotalAmount") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TotalAmount").data : string.Empty;

                markupFilter = gridSettings.where.rules.Any(r => r.field == "Markup") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "Markup").data : string.Empty;
            }

            var q = documentRepository.GetAllDocumentProducts().OrderByDescending(x => x.TimeStampTable).AsQueryable();

            if (!string.IsNullOrEmpty(codProductFilter))
            {
                q = q.Where(c => c.CodProduct != null && c.CodProduct.ToLower().Contains(codProductFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(serialFilter))
            {
                q = q.Where(c => (c.Document.EstimateNumberSerie != null && c.Document.EstimateNumberSerie.ToLower().Contains(serialFilter.ToLower())) ||
                    (c.Document.EstimateNumber != null && c.Document.EstimateNumber.ToLower().Contains(serialFilter.ToLower())) ||
                    (c.Document.CodDocument != null && c.Document.EstimateNumber != null && (c.Document.EstimateNumberSerie + "/" + c.Document.EstimateNumber).ToLower().Contains(serialFilter.ToLower())));
            }

            if (!string.IsNullOrEmpty(productNameFilter))
            {
                q = q.Where(c => c.ProductName != null && c.ProductName.ToLower().Contains(productNameFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(documentAndProductRefNameFilter))
            {
                q = q.Where(c => (c.Document.DocumentName != null && c.Document.DocumentName.ToLower().Contains(documentAndProductRefNameFilter.ToLower())) ||
                    (c.Product.ProductRefName != null && c.Product.ProductRefName.ToLower().Contains(documentAndProductRefNameFilter.ToLower())));
            }

            if (!string.IsNullOrEmpty(quantityFilter))
            {
                q = q.Where(c => c.Quantity != null && (c.Quantity ?? 0).ToString().ToLower().Contains(quantityFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(unitPriceFilter))
            {
                q = q.Where(c => c.UnitPrice != null && c.UnitPrice.ToLower().Contains(unitPriceFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(totalAmountFilter))
            {
                q = q.Where(c => c.TotalAmount != null && c.TotalAmount.ToLower().Contains(totalAmountFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(markupFilter))
            {
                q = q.Where(c => c.Markup != null && (c.Markup ?? 0).ToString().ToLower().Contains(markupFilter.ToLower()));
            }


            switch (gridSettings.sortColumn)
            {
                case "CodProduct":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.CodProduct) : q.OrderBy(c => c.CodProduct);
                    break;
                case "ProductName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.ProductName) : q.OrderBy(c => c.ProductName);
                    break;
                case "Quantity":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.Quantity) : q.OrderBy(c => c.Quantity);
                    break;
                case "UnitPrice":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.UnitPrice) : q.OrderBy(c => c.UnitPrice);
                    break;
                case "TotalAmount":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.TotalAmount) : q.OrderBy(c => c.TotalAmount);
                    break;
                case "Markup":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.Markup) : q.OrderBy(c => c.Markup);
                    break;
            }

            //var q2 = q.ToList();
            var q3 = q.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodProduct,
                        cell = new string[] 
                            {      
                                a.CodDocumentProduct,
                                a.CodProduct,
                                a.Document.EstimateNumberSerie + "/" + a.Document.EstimateNumber + "%" + a.CodDocument,
                                a.Document.DocumentName + " - " + a.Product.ProductRefName,
                                a.ProductName,  //attributo derivato
                                (a.Quantity??0).ToString(),
                                a.UnitPrice??"0",
//                                (a.Markup??0).ToString(),
                                a.TotalAmount??"0"
                            }
                    }
                ).ToArray()
            };
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #23
0
        public ActionResult TaskExecutorCylinderList(string codTaskExecutor, GridSettings gridSettings)
        {

            //read all
            var z = taskExecutorRepository.GetSingle(codTaskExecutor);

            ((Flexo)z).CheckZeroCylinder();

            var z2 = z.TaskExecutorCylinders;

            var q = z2.OrderBy(x => x.Z).AsQueryable();

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodTaskExecutorCylinder,
                        cell = new string[] 
                        {       
                            a.CodTaskExecutorCylinder,
                            a.CodTaskExecutorCylinder,
                            a.CodTaskExecutor,
                            a.Z.ToString(),
                            a.Quantity.ToString()
                         }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #24
0
ファイル: TaskCenterController.cs プロジェクト: algola/backup
        public ActionResult TaskCenterList(GridSettings gridSettings)
        {
            //use it in filter
            string codTaskCenterFilter = string.Empty;
            string taskExecutorNameFilter = string.Empty;
            string formatMaxFilter = string.Empty;


            //if gridsetting is a search option
            if (gridSettings.isSearch)
            {
                //pull search field
                codTaskCenterFilter = gridSettings.where.rules.Any(r => r.field == "CodExecutor") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "CodExecutor").data : string.Empty;

                taskExecutorNameFilter = gridSettings.where.rules.Any(r => r.field == "TaskCenterName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TaskCenterName").data : string.Empty;

            }

            //read all
            var q = taskCenterRepository.GetAll().OrderBy(x => x.IndexOf).AsQueryable();

            //execute filter
            if (!string.IsNullOrEmpty(codTaskCenterFilter))
            {
                q = q.Where(c => c.CodTaskCenter.ToLower().Contains(codTaskCenterFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(taskExecutorNameFilter))
            {
                q = q.Where(c => c.TaskCenterName.ToLower().Contains(taskExecutorNameFilter.ToLower()));
            }

            //if is sorting
            switch (gridSettings.sortColumn)
            {
                case "CodTaskCenter":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.CodTaskCenter) : q.OrderBy(c => c.CodTaskCenter);
                    break;
                case "TaskCenterName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.TaskCenterName) : q.OrderBy(c => c.TaskCenterName);
                    break;
                case "IndexOf":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.IndexOf) : q.OrderBy(c => c.IndexOf);
                    break;
            }

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodTaskCenter,
                        cell = new string[] 
                        {                                
                            a.CodTaskCenter,
                             a.CodTaskCenter,
                            a.TaskCenterName,
                            (a.IndexOf??0).ToString(),

                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);

        }
コード例 #25
0
        public ActionResult DeficitForWeightStepList(string codTaskExecutorOn, GridSettings gridSettings)
        {
            var q = StepsList(codTaskExecutorOn, gridSettings).OfType<DeficitForWeightStep>();

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.IdStep,
                        cell = new string[] 
                        {       
                            a.IdStep.ToString(),
                            a.IdStep.ToString(),
                            a.CodTaskEstimatedOn.ToString(),
                            a.FromUnit.ToString(),
                            a.ToUnit.ToString(),
                            a.DeficitRate
                         }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #26
0
        public ActionResult CustomerSupplierBaseList(string id, GridSettings gridSettings)
        {
            string addressFilter = string.Empty;
            string cityFilter = string.Empty;
            string countryFilter = string.Empty;
            string provinceFilter = string.Empty;
            
            #region filtering
            if (gridSettings.isSearch)
            {
                addressFilter = gridSettings.where.rules.Any(r => r.field == "Address") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "Address").data : string.Empty;
                cityFilter = gridSettings.where.rules.Any(r => r.field == "City") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "City").data : string.Empty;
                countryFilter = gridSettings.where.rules.Any(r => r.field == "Country") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "Country").data : string.Empty;
                provinceFilter = gridSettings.where.rules.Any(r => r.field == "Province") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "Province").data : string.Empty;
            }
            var q = customerSupplierBaseRepository.GetAll();

            q = q.Where(c => c.CodCustomerSupplier == id);
 
            if (!string.IsNullOrEmpty(addressFilter))
            {
                q = q.Where(c => c.Address.ToLower().Contains(addressFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(cityFilter))
            {
                q = q.Where(c => c.City.ToLower().Contains(cityFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(countryFilter))
            {
                q = q.Where(c => c.Country.ToLower().Contains(countryFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(provinceFilter))
            {
                q = q.Where(c => c.Province.ToLower().Contains(provinceFilter.ToLower()));
            }
            #endregion

            #region Ordering
            switch (gridSettings.sortColumn)
            {
                case "Address":
                    q = (gridSettings.sortOrder == "desc") ? 
                        q.OrderByDescending(c => c.Address) : 
                        q.OrderBy(c => c.Address);
                    break;
                case "City":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.City) :
                        q.OrderBy(c => c.City);
                    break;
                case "PostalCode":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.PostalCode) :
                        q.OrderBy(c => c.PostalCode);
                    break;
                case "Country":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.Country) :
                        q.OrderBy(c => c.Country);
                    break;
                case "Phone":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.Phone) :
                        q.OrderBy(c => c.Phone);
                    break;
                case "Fax":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.Fax) :
                        q.OrderBy(c => c.Fax);
                    break;
                case "Email":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.Email) :
                        q.OrderBy(c => c.Email);
                    break;
                case "Note":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.Note) :
                        q.OrderBy(c => c.Note);
                    break;
                case "Referee":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.Referee) :
                        q.OrderBy(c => c.Referee);
                    break;
                case "Pec":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.Pec) :
                        q.OrderBy(c => c.Pec);
                    break;
                case "Province":
                    q = (gridSettings.sortOrder == "desc") ?
                        q.OrderByDescending(c => c.Province) :
                        q.OrderBy(c => c.Province);
                    break;
            }
            #endregion

            var q2 = q.ToList();
            var q3 = q2.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();
            
            int totalRecords = q.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodCustomerSupplierBase,
                        cell = new string[] 
                        { 
                            a.CodCustomerSupplierBase,
                            a.Address,
                            a.PostalCode,
                            a.City,
                            a.Country,
                            a.Phone,
                            a.Fax,
                            a.Email,
                            a.Note,
                            a.Referee,
                            a.Pec,
                            a.Province,                        
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
コード例 #27
0
ファイル: ArticleController.cs プロジェクト: algola/backup
        public ActionResult ArticleWarehouseList(GridSettings gridSettings)
        {
            string codArticleFilter = string.Empty;
            string productNameFilter = string.Empty;
            string typeOfProductFilter = string.Empty;
            string warehouseNameFilter = string.Empty;
            string sottoScortaFilter = string.Empty;
            //read from validation's language file

            //LANGFILE
            var resman = new System.Resources.ResourceManager(typeof(Strings).FullName, typeof(Strings).Assembly);

            if (gridSettings.isSearch)
            {
                codArticleFilter = gridSettings.where.rules.Any(r => r.field == "CodArticle") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "CodArticle").data : string.Empty;

                productNameFilter = gridSettings.where.rules.Any(r => r.field == "ArticleName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "ArticleName").data : string.Empty;

                typeOfProductFilter = gridSettings.where.rules.Any(r => r.field == "TypeOfProduct") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "TypeOfProduct").data : string.Empty;

                warehouseNameFilter = gridSettings.where.rules.Any(r => r.field == "WarehouseName") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "WarehouseName").data : string.Empty;

                sottoScortaFilter = gridSettings.where.rules.Any(r => r.field == "MinQuantity") ?
                    gridSettings.where.rules.FirstOrDefault(r => r.field == "MinQuantity").data : string.Empty;
            }


            var fff = articleRepository.GetAll().ToArray();
            var q = warehouseRepository.GetAll();

            if (!string.IsNullOrEmpty(codArticleFilter))
            {
                q = q.Where(c => c.CodArticle.ToLower().Contains(codArticleFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(productNameFilter))
            {
                var names = productNameFilter.Split(' ');

                foreach (var name in names)
                {
                    q = q.Where(c => c.Article.ArticleName.ToLower().Contains(name.ToLower()));
                }

            }

            if (!string.IsNullOrEmpty(warehouseNameFilter))
            {
                q = q.Where(c => c.WarehouseSpec.WarehouseName.ToLower().Contains(warehouseNameFilter.ToLower()));
            }

            if (!string.IsNullOrEmpty(sottoScortaFilter))
            {
                q = q.Where(a => ((a.PotentialAvailable ?? 0) < (a.MinQuantity ?? 0)));
            }


            switch (gridSettings.sortColumn)
            {
                case "CodArticle":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.CodArticle) : q.OrderBy(c => c.CodArticle);
                    break;
                case "ArticleName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.Article.ArticleName) : q.OrderBy(c => c.Article.ArticleName);
                    break;
                case "WarehouseName":
                    q = (gridSettings.sortOrder == "desc") ? q.OrderByDescending(c => c.WarehouseSpec.WarehouseName) : q.OrderBy(c => c.WarehouseSpec.WarehouseName);
                    break;
            }

            var q2 = q.ToList();

            var pp = q2.OfType<WarehouseArticle>();

            var q3 = pp.Skip((gridSettings.pageIndex - 1) * gridSettings.pageSize).Take(gridSettings.pageSize).ToList();

            int totalRecords = pp.Count();

            // create json data
            int pageIndex = gridSettings.pageIndex;
            int pageSize = gridSettings.pageSize;

            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            int startRow = (pageIndex - 1) * pageSize;
            int endRow = startRow + pageSize;

            var jsonData = new
            {
                total = totalPages,
                page = pageIndex,
                records = totalRecords,
                rows =
                (
                    from a in q3
                    select new
                    {
                        id = a.CodWarehouseArticle,
                        cell = new string[] 
                        {                       
                            a.CodArticle,
                            a.CodArticle,
                            a.WarehouseSpec.WarehouseName,
                            a.Article.ArticleName,
                            ((a.PotentialAvailable??0) < (a.MinQuantity??0))?"Sotto Scorta":"",
                            a.QuantityOnHand==null?"0":a.QuantityOnHand.ToString(),
                            a.Available==null?"0":a.Available.ToString(),
                            a.PotentialQuantityOnHand==null?"0":a.PotentialQuantityOnHand.ToString(),
                            a.PotentialAvailable==null?"0":a.PotentialAvailable.ToString()
                        }
                    }
                ).ToArray()
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }