コード例 #1
0
        public DataSourceResult GetOrders(DataSourceRequest request)
        {
            Hashtable fltr = new Hashtable();

            Common.CommonFunction.PopulateFiltersInHashTable(request.Filters, fltr);

            ObjectParameter objparam = new ObjectParameter("TotalRecords", System.Data.DbType.Int16);

            var      distribut = fltr.ContainsKey("Distributor") ? Convert.ToInt32(fltr["Distributor"].ToString()) : 0;
            DateTime?orderDate = (fltr.ContainsKey("Date") && fltr["Date"] != null) ? Convert.ToDateTime(fltr["Date"]) : (DateTime?)null;

            var queryResult = db.Order_Get(orderDate, distribut, request.Page, request.PageSize, objparam).ToList()
                              .Select(i => new OrderViewModel()
            {
                OrderId           = i.OrderId,
                Date              = i.ModifiedDate.Date.ToString("dd MMM yyy"),
                Distributor       = i.Distributor,
                IsDispatched      = i.IsDispatched,
                TotalItems        = (int)i.TotalItems,
                TotalItemsPending = (int)i.TotalItemsPending,
                ProcessOrder      = CryptographyUtility.GetEncryptedQueryString(new { orderId = i.OrderId }),
                ViewOrder         = CryptographyUtility.GetEncryptedQueryString(new { orderId = i.OrderId })
            });

            DataSourceResult dsr = new DataSourceResult();

            dsr.Data  = queryResult;
            dsr.Total = (int)objparam.Value;

            return(dsr);
        }
コード例 #2
0
        public DataSourceResult GetItems(DataSourceRequest request)
        {
            Hashtable fltr = new Hashtable();

            Common.CommonFunction.PopulateFiltersInHashTable(request.Filters, fltr);

            string sortBy = string.Empty;

            if (request.Sorts.Any())
            {
                sortBy = request.Sorts[0].Member + " " + request.Sorts[0].SortDirection;
            }

            ObjectParameter objparam = new ObjectParameter("TotalRecords", System.Data.DbType.Int16);

            var name      = fltr.ContainsKey("Name") ? fltr["Name"].ToString() : null;
            var distribut = fltr.ContainsKey("Distributor") ? fltr["Distributor"].ToString() : null;
            var manufact  = fltr.ContainsKey("Manufacturer") ? fltr["Manufacturer"].ToString() : null;
            var locat     = fltr.ContainsKey("Location") ? fltr["Location"].ToString() : null;

            var categ = fltr.ContainsKey("Category") ? Convert.ToInt32(fltr["Category"]) : 0;

            var queryResult = db.Item_Get(name, distribut, manufact, locat, categ, request.Page, request.PageSize, sortBy, objparam).ToList()
                              .Select(i => new ItemViewModel()
            {
                ManufacturerId   = i.ManufacturerId ?? 0,
                ManufacturerName = i.Manufacturer ?? "",
                Name             = i.Name,
                CategoryId       = i.CategoryId,
                CategoryName     = i.Category,
                DistributorId    = i.DistributorId ?? 0,
                DistributorName  = i.Distributor ?? "",
                Code             = i.Code ?? "",
                Formula          = i.Formula ?? "",
                ItemId           = i.ItemId,
                LocationId       = i.LocationId ?? 0,
                Status           = (i.IsActive) ? "Active" : "Inactive",
                LocationName     = i.Location ?? "",
                PiecesInPaking   = i.PiecesInPacking ?? 0,
                PurchasePrice    = i.PurchasePrice,
                SalePrice        = i.SalePrice ?? 0,
                UnitPrice        = i.UnitPrice ?? 0,
                TotalStock       = (int)i.TotalStock,
                IsActive         = i.IsActive,
                EditItemUrl      = CryptographyUtility.GetEncryptedQueryString(new { itemId = i.ItemId })
            });

            DataSourceResult dsr = new DataSourceResult();

            dsr.Data  = queryResult;
            dsr.Total = (int)objparam.Value;

            return(dsr);
        }
コード例 #3
0
        public DataSourceResult GetInvoices(DataSourceRequest request)
        {
            Hashtable fltr = new Hashtable();

            Common.CommonFunction.PopulateFiltersInHashTable(request.Filters, fltr);

            string sortBy = string.Empty;

            if (request.Sorts.Any())
            {
                sortBy = request.Sorts[0].Member + " " + request.Sorts[0].SortDirection;
            }

            ObjectParameter objparam = new ObjectParameter("TotalRecords", System.Data.DbType.Int16);

            int      invoice = 0;
            DateTime date    = new DateTime();

            if (fltr.ContainsKey("Date"))
            {
                DateTime.TryParse(fltr["Date"].ToString(), out date);
            }

            if (fltr.ContainsKey("InvoiceNo"))
            {
                int.TryParse(fltr["InvoiceNo"].ToString(), out invoice);
            }

            var queryResult = db.Invoice_Get(date, invoice, request.Page, request.PageSize, sortBy, objparam).ToList()
                              .Select(m => new InvoiceViewModel()
            {
                InvoiceId      = m.InvoiceId,
                AddedOn        = m.AddedOn,
                AmountRecieved = m.AmountRecieved,
                Discount       = m.DiscountAmount,
                NoOfItems      = m.NoOfItems,
                TotalPrice     = m.TotalPrice,
                ViewInvoiceUrl = CryptographyUtility.GetEncryptedQueryString(new { InvoiceId = m.InvoiceId })
            });

            DataSourceResult dsr = new DataSourceResult();

            dsr.Data  = queryResult;
            dsr.Total = (int)objparam.Value;

            return(dsr);
        }
コード例 #4
0
        public DataSourceResult GetManufacturers(DataSourceRequest request)
        {
            Hashtable fltr = new Hashtable();

            Common.CommonFunction.PopulateFiltersInHashTable(request.Filters, fltr);

            string sortBy = string.Empty;

            if (request.Sorts.Any())
            {
                sortBy = request.Sorts[0].Member + " " + request.Sorts[0].SortDirection;
            }

            ObjectParameter objparam = new ObjectParameter("TotalRecords", System.Data.DbType.Int16);

            var name  = fltr.ContainsKey("Name") ? fltr["Name"].ToString() : string.Empty;
            var alias = fltr.ContainsKey("Alias") ? fltr["Alias"].ToString() : null;
            var phone = fltr.ContainsKey("Phone") ? fltr["Phone"].ToString() : null;

            var queryResult = db.Manufacturer_Get(name, alias, phone, request.Page, request.PageSize, sortBy, objparam).ToList()
                              .Select(m => new ManufacturerViewModel()
            {
                ManufactId          = m.ManufacturerId,
                Name                = m.Name,
                Alias               = m.Alias,
                Address             = m.Address,
                City                = m.City,
                Country             = m.Country,
                Status              = (m.IsActive) ? "Active" : "Inactive",
                IsActive            = m.IsActive,
                Phone               = m.Phone,
                EditManufacturerUrl = CryptographyUtility.GetEncryptedQueryString(new { manufactId = m.ManufacturerId })
            });

            DataSourceResult dsr = new DataSourceResult();

            dsr.Data  = queryResult;
            dsr.Total = (int)objparam.Value;

            return(dsr);
        }
コード例 #5
0
        public DataSourceResult GetDistributors(DataSourceRequest request)
        {
            Hashtable fltr = new Hashtable();

            Common.CommonFunction.PopulateFiltersInHashTable(request.Filters, fltr);

            string sortBy = string.Empty;

            if (request.Sorts.Any())
            {
                sortBy = request.Sorts[0].Member + " " + request.Sorts[0].SortDirection;
            }

            ObjectParameter objparam = new ObjectParameter("TotalRecords", System.Data.DbType.Int16);

            var name    = fltr.ContainsKey("Name") ? fltr["Name"].ToString() : string.Empty;
            var company = fltr.ContainsKey("Company") ? fltr["Company"].ToString() : null;
            var phone   = fltr.ContainsKey("Phone") ? fltr["Phone"].ToString() : null;

            var queryResult = db.Distributor_Get(name, company, phone, request.Page, request.PageSize, sortBy, objparam).ToList()
                              .Select(d => new DistributorViewModel()
            {
                DistributorId      = d.DistributorId,
                Name               = d.Name,
                Company            = d.Company,
                Address            = d.Address,
                City               = d.City,
                IsActive           = d.IsActive,
                Status             = (d.IsActive) ? "Active" : "Inactive",
                Phone              = d.Phone,
                EditDistributorUrl = CryptographyUtility.GetEncryptedQueryString(new { distributId = d.DistributorId })
            });

            DataSourceResult dsr = new DataSourceResult();

            dsr.Data  = queryResult;
            dsr.Total = (int)objparam.Value;

            return(dsr);
        }