Beispiel #1
0
        public ActionResult DashboardLevel4(string Type, string Region, string Zone)
        {
            if (string.IsNullOrWhiteSpace(Type))
            {
                Type = "FAS";
            }
            FASViewModel vm = new FASViewModel();

            vm.DateFrom = user.DateFrom;
            vm.DateTo   = user.DateTo;
            vm.SelectedCompanies.Add(user.CompCode.ToString());
            if (!string.IsNullOrEmpty(Region))
            {
                Region region = FASRepo.GetRegion(int.Parse(Region));
                ViewBag.Region = region.Name;
                vm.SelectedRegions.Add(Region);
            }
            if (!string.IsNullOrEmpty(Zone))
            {
                Zone zone = FASRepo.GetZone(Zone);
                ViewBag.Zone = zone.Name;
                vm.SelectedZones.Add(Zone);
            }

            var k = FASRepo.GetTerritoryBoxes(Type, FASRepo.GetWhereClause(vm, Type, 1, user.UserID), user.UserID);


            return(View(k));
        }
Beispiel #2
0
        public ActionResult Details(FASViewModel vm)
        {
            if (vm.SelectedCompanies == null)
            {
                vm.SelectedCompanies = new List <string>();
            }
            if (vm.SelectedRegions == null)
            {
                vm.SelectedRegions = new List <string>();
            }
            if (vm.SelectedTerritories == null)
            {
                vm.SelectedTerritories = new List <string>();
            }
            if (vm.SelectedZones == null)
            {
                vm.SelectedZones = new List <string>();
            }
            vm.Companies   = CompanyRepo.GetCompanies(user.UserID);
            vm.Regions     = FASRepo.GetRegions(1, vm.SelectedCompanies.Select(x => x.ToString()).ToList(), user.UserID);
            vm.Zones       = FASRepo.GetZones(1, vm.SelectedCompanies.Select(x => x.ToString()).ToList(), vm.SelectedRegions.Select(x => x.ToString()).ToList(), user.UserID);
            vm.Territories = FASRepo.GeTerritories(1, vm.Companies.Select(x => x.Compcode.ToString()).ToList(), vm.SelectedRegions.Select(x => x.ToString()).ToList(), vm.SelectedZones.Select(x => x.ToString()).ToList(), user.UserID);

            ViewBag.WhereClause = FASRepo.GetWhereClause(vm, "FAS", 1, user.UserID);

            var list = FASRepo.GetDetails("FAS", FASRepo.GetWhereClause(vm, "FAS", 1, user.UserID), user.UserID);

            ViewBag.ListDetails = list;
            return(View(vm));
        }
Beispiel #3
0
        public ActionResult DashboardLevel2(string Type)
        {
            if (string.IsNullOrWhiteSpace(Type))
            {
                Type = "FAS";
            }
            FASViewModel vm = new FASViewModel();

            vm.DateFrom = user.DateFrom;
            vm.DateTo   = user.DateTo;
            vm.SelectedCompanies.Add(user.CompCode.ToString());

            var k = FASRepo.GetRegionBoxes(Type, FASRepo.GetWhereClause(vm, Type, 1, user.UserID), user.UserID);

            return(View(k));
        }
        public ActionResult ActivityDetails()
        {
            ActivityDetails_VM displayVM = new ActivityDetails_VM();

            FASViewModel vm = new FASViewModel();

            vm.SelectedCompanies.Add(user.CompCode.ToString());
            vm.DateFrom = user.DateFrom;
            vm.DateTo   = user.DateTo;
            try
            {
                displayVM.FASBox  = FASRepo.GetCompanyCount("FAS", FASRepo.GetWhereClause(vm, "FAS", 1, user.UserID), user.UserID).First();
                displayVM.DemoBox = FASRepo.GetCompanyCount("Demo", FASRepo.GetWhereClause(vm, "Demo", 1, user.UserID), user.UserID).First();
                displayVM.FDBox   = FASRepo.GetCompanyCount("F/D", FASRepo.GetWhereClause(vm, "F/D", 1, user.UserID), user.UserID).First();
            }
            catch (Exception ex)
            {
                //displayVM = new ActivityDetails_VM();
            }
            return(View(displayVM));
        }
Beispiel #5
0
        public string GetWhereClause(FASViewModel vm, string Type, int SessionGroupType, int UserID)
        {
            if (vm.DateFrom == null)
            {
                vm.DateFrom = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-") + "01");
            }
            if (vm.DateTo == null)
            {
                vm.DateTo = DateTime.Now;
            }

            string Where = $"Where ( T.Compcode in ({string.Join(",", vm.SelectedCompanies)}) ) ";

            if (vm.SelectedRegions != null && vm.SelectedRegions.Where(x => !string.IsNullOrWhiteSpace(x)).ToList().Count > 0)
            {
                Where += $" AND T.Regionid in ({string.Join(",", vm.SelectedRegions)})";
            }
            if (vm.SelectedZones == null || vm.SelectedZones.Count == 0)
            {
                if (SessionGroupType == 1)
                {
                    Where += $" AND (T.Zoneid in ( SELECT distinct [Zoneid] FROM zone WHERE [Compcode] in ({string.Join(",", vm.SelectedCompanies)})) ) ";
                }
                else
                {
                    Where += $" AND (T.Zoneid in ( SELECT distinct [Zoneid] FROM Viewuserzoneregion WHERE [Compcode] in ({string.Join(",", vm.SelectedCompanies)}) AND Uid = {UserID}) ) ";
                }
            }
            else
            {
                Where += $"  AND  ( T.zoneid in  ({string.Join(",",vm.SelectedZones)}) )";
            }
            if (vm.SelectedTerritories != null && vm.SelectedTerritories.Count > 0)
            {
                Where += $"  AND  ( T.Territoryid in  ({string.Join(",", vm.SelectedTerritories)}) )";
            }
            if (vm.SelectedDistricts != null && vm.SelectedDistricts.Count > 0)
            {
                Where += $"  AND isnull(D.VID,0) = {vm.SelectedDistricts.First()}  ";
            }
            if (vm.SelectedVillages != null && vm.SelectedVillages.Count > 0)
            {
                Where += $"  AND V.VID = {vm.SelectedVillages.First()}";
            }
            if (vm.SelectedFarmers != null && vm.SelectedFarmers.Count > 0)
            {
                Where += $"  AND F.VID = {string.Join(",", vm.SelectedFarmers.First())}";
            }
            if (vm.SelectedStatus != null && vm.SelectedStatus.Count > 0)
            {
                Where += $"  AND H.VStatus = {vm.SelectedStatus.First()}";
            }
            if (vm.SelectedCrops != null && vm.SelectedCrops.Count > 0)
            {
                Where += $" AND CR.CropID = {vm.SelectedCrops.First()}";
            }
            if (vm.SelectedCategories != null && vm.SelectedCategories.Count > 0)
            {
                Where += $"   AND  ( P.Categoryid in  ({string.Join(",", vm.SelectedCategories)}) )";
            }
            if (vm.SelectedProducts != null && vm.SelectedProducts.Count > 0)
            {
                Where += $"   AND  ( P.Productid in   ({string.Join(",", vm.SelectedProducts)}) )";
            }
            if (vm.SelectedSpecs != null && vm.SelectedSpecs.Count > 0)
            {
                Where += $"  AND  ( P.Specid in  ({string.Join(",", vm.SelectedTerritories)}) )";
            }
            if (Type == "FAS")
            {
                Where += $" AND (H.VisitDate between '{((DateTime)vm.DateFrom).ToString("yyyy-MM-dd")}' and '{((DateTime)vm.DateTo).ToString("yyyy-MM-dd")}' )";
            }
            else if (Type == "Demo")
            {
                Where += $" AND (H.TrialDate between '{((DateTime)vm.DateFrom).ToString("yyyy-MM-dd")}' and '{((DateTime)vm.DateTo).ToString("yyyy - MM - dd")}' )";
            }
            else if (Type == "F/D")
            {
                Where += $" AND (H.FDDate between '{((DateTime)vm.DateFrom).ToString("yyyy-MM-dd")}' and '{((DateTime)vm.DateTo).ToString("yyyy-MM-dd")}' )";
            }
            //Where += $" AND (H.VisitDate between '{((DateTime)vm.DateFrom).ToString("yyyy-MM-dd")}' and  '{((DateTime)vm.DateTo).ToString("yyyy-MM-dd")}' )";
            if (vm.AcreageTo != 0 && vm.AcrageFrom != 0)
            {
                Where += $" AND (H.TotAcreage between {vm.AcrageFrom} and {vm.AcreageTo} )";
            }
            return(Where);
        }
Beispiel #6
0
        public ActionResult Details(string Type, string Region, string Zone, string Territory)
        {
            if (string.IsNullOrWhiteSpace(Type))
            {
                Type = "FAS";
            }
            FASViewModel vm = new FASViewModel();

            vm.SelectedCompanies = new List <string>();
            vm.Companies         = CompanyRepo.GetCompanies(user.UserID);
            vm.SelectedCompanies = new List <string>();
            vm.SelectedCompanies.Add(user.CompCode.ToString());

            vm.Regions = FASRepo.GetRegions(1, vm.SelectedCompanies, user.UserID);


            vm.SelectedRegions = new List <string>();
            if (!string.IsNullOrEmpty(Region))
            {
                Region region = FASRepo.GetRegion(int.Parse(Region));
                ViewBag.Region = region.Name;

                vm.SelectedRegions.Add(Region);
            }

            if (vm.SelectedRegions.Count != 0)
            {
                vm.Zones = FASRepo.GetZones(1, vm.SelectedCompanies, vm.SelectedRegions, user.UserID);
            }
            else
            {
                vm.Zones = FASRepo.GetZones(1, vm.SelectedCompanies, vm.Regions.Select(x => x.ID.ToString()).ToList(), user.UserID);
            }

            vm.SelectedZones = new List <string>();
            if (!string.IsNullOrEmpty(Zone))
            {
                Zone zone = FASRepo.GetZone(Zone);
                ViewBag.Zone = zone.Name;
                vm.SelectedZones.Add(Zone);
            }

            if (vm.SelectedZones.Count != 0)
            {
                if (vm.SelectedRegions.Count != 0)
                {
                    vm.Territories = FASRepo.GeTerritories(1, vm.SelectedCompanies, vm.SelectedRegions, vm.SelectedZones, user.UserID);
                }
                else
                {
                    vm.Territories = FASRepo.GeTerritories(1, vm.SelectedCompanies, vm.Regions.Select(x => x.ID.ToString()).ToList(), vm.SelectedZones, user.UserID);
                }
            }
            else
            {
                vm.Territories = FASRepo.GeTerritories(1, vm.SelectedCompanies, vm.Regions.Select(x => x.ID.ToString()).ToList(), vm.Zones.Select(x => x.ID.ToString()).ToList(), user.UserID);
            }

            vm.SelectedTerritories = new List <string>();
            if (!string.IsNullOrEmpty(Territory))
            {
                Territory territory = FASRepo.GetTerritory(Territory);
                ViewBag.Territory = territory.Name;

                vm.SelectedTerritories.Add(Territory);
            }

            vm.DateFrom = user.DateFrom;
            vm.DateTo   = user.DateTo;
            var list = FASRepo.GetDetails(Type, FASRepo.GetWhereClause(vm, Type, 1, user.UserID), user.UserID);

            ViewBag.ListDetails = list;
            return(View(vm));
        }