Exemplo n.º 1
0
        public JsonResult SalePointList(string SalePointName)
        {
            var selectList = new List <SelectListItem>();
            var areainfo   = AgroExpressDBAccess.GetSalePointByName(SalePointName);
            var areaList   = AgroExpressDBAccess.GetAreaBySalePointID(areainfo.PKSalePointID);

            if (areaList != null)
            {
                foreach (var area in areaList)
                {
                    selectList.Add(new SelectListItem
                    {
                        Value = area.PKAreaId.ToString(),
                        Text  = area.AreaName,
                    });
                }
            }
            return(Json(selectList, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult EnabledCustomer(CustomerListView culist)
        {
            List <Customer> customerlist = AgroExpressDBAccess.GetallEnabledCustomer();
            List <Area>     AreList      = new List <Area>();


            if (culist.CustomerID != null)
            {
                customerlist = customerlist.Where(a => a.PKCustomerId == culist.CustomerID).ToList();
            }
            if (culist.Mobile != null)
            {
                customerlist = customerlist.Where(a => a.Mobile == culist.Mobile).ToList();
            }
            if (culist.SubAreaId != null)
            {
                customerlist = customerlist.Where(a => a.SubAreaId == culist.SubAreaId).ToList();
            }
            List <SubArea> subAreList = AgroExpressDBAccess.GetallEnabledSubArea();

            if (culist.SalePointId != null)
            {
                AreList = AgroExpressDBAccess.GetAreaBySalePointID((int)culist.SalePointId);

                if (AreList != null)
                {
                    subAreList = subAreList
                                 .Where(x => AreList.Any(y => y.PKAreaId == x.AreaId)).ToList();
                }
                customerlist = customerlist.Where(customer => subAreList.Any(subarea => subarea.PKSubAreaId == customer.SubAreaId)).ToList();
            }
            if (culist.AreaId != null)
            {
                subAreList = subAreList
                             .Where(x => x.AreaId == culist.AreaId).ToList();
                customerlist = customerlist.Where(customer => subAreList.Any(subarea => subarea.PKSubAreaId == customer.SubAreaId)).ToList();
            }
            if (culist.RateMin != null)
            {
                customerlist = customerlist.Where(a => a.Rate >= culist.RateMin).ToList();
            }
            if (culist.RateMax != null)
            {
                customerlist = customerlist.Where(a => a.Rate <= culist.RateMax).ToList();
            }

            if (culist.DueMin != null)
            {
                customerlist = customerlist.Where(a => (a.TotalBill - a.TotalPaid) >= culist.DueMin).ToList();
            }
            if (culist.DueMax != null)
            {
                customerlist = customerlist.Where(a => (a.TotalBill - a.TotalPaid) <= culist.DueMax).ToList();
            }
            List <SalePoint> salepointlist = AgroExpressDBAccess.GetallEnabledSalePoint();

            if (salepointlist != null)
            {
                culist.salepointlist = salepointlist.Select(x => new SelectListItem
                {
                    Value = x.PKSalePointID.ToString(),
                    Text  = x.SalePointName
                });
            }

            List <Area> arealist = AgroExpressDBAccess.GetallEnabledArea();

            if (arealist != null)
            {
                culist.arealist = arealist.Select(x => new SelectListItem
                {
                    Value = x.PKAreaId.ToString(),
                    Text  = x.AreaName
                });
            }

            List <SubArea> sarealist = AgroExpressDBAccess.GetallEnabledSubArea();

            if (sarealist != null)
            {
                culist.subarealist = sarealist.Select(x => new SelectListItem
                {
                    Value = x.PKSubAreaId.ToString(),
                    Text  = x.SubAreaName
                });
            }

            culist.customerlist = customerlist;

            culist.customerlist = customerlist;
            //culist.StartValue = culist.StartValue;
            //culist.EndValue = culist.EndValue;
            culist.Mobile = culist.Mobile;
            //culist.Rate = culist.Rate;

            if (customerlist != null)
            {
                culist.selectedcustomerlist = customerlist.Select(x => new SelectListItem
                {
                    Value = x.PKCustomerId.ToString(),
                    Text  = x.FullName
                });
            }

            return(View(culist));
        }
        public ActionResult BillHistory(BillHistory listview)
        {
            List <SalePoint> salepointlist = AgroExpressDBAccess.GetallEnabledSalePoint();

            if (salepointlist != null)
            {
                listview.salepointlist = salepointlist.Select(x => new SelectListItem
                {
                    Value = x.PKSalePointID.ToString(),
                    Text  = x.SalePointName
                });
            }

            List <Area> arealist = AgroExpressDBAccess.GetallEnabledArea();

            if (arealist != null)
            {
                listview.arealist = arealist.Select(x => new SelectListItem
                {
                    Value = x.PKAreaId.ToString(),
                    Text  = x.AreaName
                });
            }

            List <SubArea> sarealist = AgroExpressDBAccess.GetallEnabledSubArea();

            if (sarealist != null)
            {
                listview.subarealist = sarealist.Select(x => new SelectListItem
                {
                    Value = x.PKSubAreaId.ToString(),
                    Text  = x.SubAreaName
                });
            }

            var customerlist = AgroExpressDBAccess.GetallEnabledCustomer();

            if (customerlist != null)
            {
                listview.selectedcustomerlist = customerlist.Select(x => new SelectListItem
                {
                    Value = x.PKCustomerId.ToString(),
                    Text  = x.FullName
                });
            }

            var billinfo = AgroExpressDBAccess.GetBillingInfoByDate(listview.EntryDateMin, listview.EntryDateMax.AddDays(1));

            if (listview.PaidAmountVMax != null)
            {
                billinfo = billinfo.Where(a => a.BillPaid <= listview.PaidAmountVMax).ToList();
            }
            if (listview.PaidAmountVMin != null)
            {
                billinfo = billinfo.Where(a => a.BillPaid >= listview.PaidAmountVMin).ToList();
            }

            if (listview.CustomerID != null)
            {
                billinfo = billinfo.Where(a => a.CustomerId == listview.CustomerID).ToList();
            }

            List <Area>    AreList    = new List <Area>();
            List <SubArea> subAreList = AgroExpressDBAccess.GetallEnabledSubArea();

            if (listview.SalePointId != null)
            {
                AreList = AgroExpressDBAccess.GetAreaBySalePointID((int)listview.SalePointId);

                if (AreList != null)
                {
                    subAreList = subAreList
                                 .Where(x => AreList.Any(y => y.PKAreaId == x.AreaId)).ToList();
                }
                customerlist = customerlist.Where(customer => subAreList.Any(subarea => subarea.PKSubAreaId == customer.SubAreaId)).ToList();
                billinfo     = billinfo.Where(salei => customerlist.Any(customer => customer.PKCustomerId == salei.CustomerId)).ToList();
            }
            if (listview.AreaId != null)
            {
                subAreList   = subAreList.Where(su => su.AreaId == listview.AreaId).ToList();
                customerlist = customerlist.Where(customer => subAreList.Any(subarea => subarea.PKSubAreaId == customer.SubAreaId)).ToList();
                billinfo     = billinfo.Where(salei => customerlist.Any(customer => customer.PKCustomerId == salei.CustomerId)).ToList();
            }
            if (listview.SubAreaId != null)
            {
                customerlist = customerlist.Where(customer => customer.SubAreaId == listview.SubAreaId).ToList();
                billinfo     = billinfo.Where(salei => customerlist.Any(customer => customer.PKCustomerId == salei.CustomerId)).ToList();
            }
            List <BillingHistoryListView> bill = new List <BillingHistoryListView>();

            if (billinfo != null)
            {
                foreach (var li in billinfo)
                {
                    bill.Add(new BillingHistoryListView
                    {
                        DateTime     = li.DateTime,
                        CustomerName = li.customer.FullName,
                        BillPaid     = li.BillPaid,
                        OperatorName = li.OperatorName
                    });
                }
            }

            listview.allbills = bill;
            return(View(listview));
        }
        public ActionResult SaleHistory(SaleListView listview)
        {
            List <SalePoint> salepointlist = AgroExpressDBAccess.GetallEnabledSalePoint();

            if (salepointlist != null)
            {
                listview.salepointlist = salepointlist.Select(x => new SelectListItem
                {
                    Value = x.PKSalePointID.ToString(),
                    Text  = x.SalePointName
                });
            }

            List <Area> arealist = AgroExpressDBAccess.GetallEnabledArea();

            if (arealist != null)
            {
                listview.arealist = arealist.Select(x => new SelectListItem
                {
                    Value = x.PKAreaId.ToString(),
                    Text  = x.AreaName
                });
            }

            List <SubArea> sarealist = AgroExpressDBAccess.GetallEnabledSubArea();

            if (sarealist != null)
            {
                listview.subarealist = sarealist.Select(x => new SelectListItem
                {
                    Value = x.PKSubAreaId.ToString(),
                    Text  = x.SubAreaName
                });
            }

            var customerlist = AgroExpressDBAccess.GetallEnabledCustomer();

            if (customerlist != null)
            {
                listview.selectedcustomerlist = customerlist.Select(x => new SelectListItem
                {
                    Value = x.PKCustomerId.ToString(),
                    Text  = x.FullName
                });
            }
            var productList = AgroExpressDBAccess.GetAllEnabledProduct();

            if (productList != null)
            {
                listview.selectedproductlist = productList.Select(x => new SelectListItem
                {
                    Value = x.PKProductId.ToString(),
                    Text  = x.ProductName
                });
            }
            var saleifo = AgroExpressDBAccess.GetSaleInfoByDate(listview.EntryDateMin, listview.EntryDateMax.AddDays(1));

            if (listview.AmountVMax != null)
            {
                saleifo = saleifo.Where(a => a.Amount <= listview.AmountVMax).ToList();
            }
            if (listview.AmountVMin != null)
            {
                saleifo = saleifo.Where(a => a.Amount >= listview.AmountVMin).ToList();
            }

            if (listview.CustomerID != null)
            {
                saleifo = saleifo.Where(a => a.CustomerId == listview.CustomerID).ToList();
            }
            if (listview.SelectedProductID != null)
            {
                saleifo = saleifo.Where(a => a.ProductId == listview.SelectedProductID).ToList();
            }
            List <Area>    AreList    = new List <Area>();
            List <SubArea> subAreList = AgroExpressDBAccess.GetallEnabledSubArea();

            if (listview.SalePointId != null)
            {
                AreList = AgroExpressDBAccess.GetAreaBySalePointID((int)listview.SalePointId);

                if (AreList != null)
                {
                    subAreList = subAreList
                                 .Where(x => AreList.Any(y => y.PKAreaId == x.AreaId)).ToList();
                }
                customerlist = customerlist.Where(customer => subAreList.Any(subarea => subarea.PKSubAreaId == customer.SubAreaId)).ToList();
                saleifo      = saleifo.Where(salei => customerlist.Any(customer => customer.PKCustomerId == salei.CustomerId)).ToList();
            }
            if (listview.AreaId != null)
            {
                subAreList   = subAreList.Where(su => su.AreaId == listview.AreaId).ToList();
                customerlist = customerlist.Where(customer => subAreList.Any(subarea => subarea.PKSubAreaId == customer.SubAreaId)).ToList();
                saleifo      = saleifo.Where(salei => customerlist.Any(customer => customer.PKCustomerId == salei.CustomerId)).ToList();
            }
            if (listview.SubAreaId != null)
            {
                customerlist = customerlist.Where(customer => customer.SubAreaId == listview.SubAreaId).ToList();
                saleifo      = saleifo.Where(salei => customerlist.Any(customer => customer.PKCustomerId == salei.CustomerId)).ToList();
            }

            List <SaleList> sale = new List <SaleList>();

            if (saleifo != null)
            {
                foreach (var li in saleifo)
                {
                    sale.Add(new SaleList
                    {
                        DateTime     = li.DateTime,
                        CustomerName = li.customer.FullName,
                        ProductName  = li.product.ProductName,
                        Amount       = li.Amount,
                        SMSSent      = li.SMSSent,
                        OperatorName = li.OperatorName
                    });
                }
            }

            listview.salelist = sale;
            return(View(listview));
        }