예제 #1
0
        // GET: DataEntryGarbage
        public ActionResult ViewGarbage(int?CompanyId)
        {
            SearchGarbageInformation searchGarbageInformation = new SearchGarbageInformation();

            if (CompanyId != null)
            {
                var    userid    = User.Identity.GetUserId();
                string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
                //searchGarbageInformation.BillingPeriods = db.BillingPeriod.Where(m => m.Finalized == "No").Where(m => m.groupCode == ZoneGroup).ToList();
                var username = User.Identity.GetUserName();
                RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);
                ViewBag.IsValidRole = roleAssignmentMatrix.Garbage;

                searchGarbageInformation.Companies = db.Company.Where(m => m.CompanyID == CompanyId).ToList();
                //searchGarbageInformation.BillingPeriods = db.BillingPeriod.Where(m => m.Finalized == "No").Where(m => m.groupCode == ZoneGroup).ToList();
                IEnumerable <BillingPeriod> IBillingPeriods = db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).ToList();
                searchGarbageInformation.BillingPeriods      = IBillingPeriods.OrderByDescending(m => m.BillingPeriodId).ToList();
                searchGarbageInformation.BillingRates        = db.BillingRates.Where(m => m.Category == "Garbage Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList();
                searchGarbageInformation.GarbageInformations = db.GarbageInformations.Where(m => m.CompanyId == CompanyId).ToList();
                //var subCategory = searchGarbageInformation.BillingRates.GroupBy(m => m.SubCategory).Select(g => new { SubCategory = g.Key }).ToList();
                var subcat1 = searchGarbageInformation.BillingRates.GroupBy(m => m.SubCategory).ToList();

                foreach (var item in subcat1)
                {
                    searchGarbageInformation.SubCategory.Add(item.Key.ToString());
                }
                ViewBag.CompanySelected = "OK";
            }

            return(View(searchGarbageInformation));
        }
        public ActionResult DisplayPoleRentalList(int CompanyId, FormCollection frmcollection)
        {
            var userid   = User.Identity.GetUserId();
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Pole;

            ViewBag.CompanySelected = "OK";
            if (frmcollection.Count == 0)
            {
                SearchPoleInformationViewModel SearchCompanyViewModels = new SearchPoleInformationViewModel();
                SearchCompanyViewModels.PoleInformationList = db.PoleInformation.SqlQuery("Select * from PoleInformations where CompanyId = '" + frmcollection["CompanyId"] + "'").ToList();
                return(View(SearchCompanyViewModels));
            }
            else if (frmcollection.Count >= 1)
            {
                int parsedID = int.Parse(frmcollection["PoleInformationId"]);
                SearchPoleInformationViewModel SearchPoleRentalViewModels = new SearchPoleInformationViewModel();
                PoleInformation PoleRentalAssignment = new PoleInformation();
                PoleInformation pole = db.PoleInformation.Find(parsedID);
                db.PoleInformation.Remove(pole);
                db.SaveChanges();
                SearchPoleRentalViewModels.CompanyList         = db.Company.Where(m => m.CompanyID == CompanyId).ToList();
                SearchPoleRentalViewModels.PoleInformationList = db.PoleInformation.Where(m => m.CompanyId == CompanyId).ToList();
                return(View("ViewPoleRentals", SearchPoleRentalViewModels));
            }
            return(View());
        }
예제 #3
0
        public ActionResult Finalize(int id)
        {
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Billing;

            BillingRegenerateBLL billingRegenerateBLL = new BillingRegenerateBLL(id);

            if (billingRegenerateBLL.FinalizeBilling())
            {
                Response.Write("Billing period has been finalized.");
                SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Generate- Billing period has been finalized.  - from Terminal: " + ipaddress);
            }
            else
            {
                Response.Write("Failed to finalize billing period. Please contact your system administrator.");
                SL.LogError(User.Identity.Name, Request.RawUrl, "Billing Generate -Failed to finalize billing period  - from Terminal: " + ipaddress);
            }
            var userid = User.Identity.GetUserId();
            ApplicationUserManager UserManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); //initialize usermanager
            var rolename          = UserManager.GetRoles(userid).FirstOrDefault();                                       //get the role name of current user
            UserAccessControl uac = new UserAccessControl("billing", rolename);

            ViewBag.IsValidRole = uac.userCanAccess();

            List <BillingPeriod> billingperiodlist = new List <BillingPeriod>();

            billingperiodlist = db.BillingPeriod.ToList();
            //return View("ViewGenerate", billingperiodlist);
            return(RedirectToAction("ViewGeneratePRG", "BillingGenerate"));
        }
        // GET:
        public ActionResult ViewPeriodTable(FormCollection frm)
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var    userid    = User.Identity.GetUserId();
            var    username  = User.Identity.GetUserName();
            string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Period;

            if (frm.Count == 0)
            {
                SearchBillingPeriodViewModel SearchPeriodViewModels = new SearchBillingPeriodViewModel();
                SearchPeriodViewModels.BillPeriodList = db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).OrderByDescending(n => n.DateFrom).ToList();
                return(View(SearchPeriodViewModels));
            }
            else if (frm.Count >= 1)
            {
                int           parsedID = int.Parse(frm["ID"]);
                BillingPeriod period   = db.BillingPeriod.Find(parsedID);
                db.BillingPeriod.Remove(period);
                db.SaveChanges();
                return(RedirectToAction("ViewPeriodTable"));
            }
            return(View());
        }
예제 #5
0
        public ActionResult ViewWaterReading(int?CompanyID, string MeterNum)
        {
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            var    username  = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Water;

            SearchWaterViewModel SearchWaterViewModels = new SearchWaterViewModel();

            if (CompanyID != null)
            {
                SearchWaterViewModels.Companies             = db.Company.Where(m => m.CompanyID == CompanyID).ToList();
                SearchWaterViewModels.WaterMeterAssignments = db.WaterMeterAssignment.Where(m => m.MeterNumber == MeterNum).ToList();
                SearchWaterViewModels.WaterMeterReadings    = db.WaterMeterReading.Where(m => m.MeterNumber == MeterNum).OrderByDescending(m => m.PresentReading).ToList();
                SearchWaterViewModels.BillingPeriods        = BillingPeriods();
            }

            SearchWaterViewModels.BillingPeriods = BillingPeriods();
            decimal?sewerageRate = db.BillingRates.FirstOrDefault(m => m.ZoneGroup == ZoneGroup && m.Category.ToUpper() == "SEWERAGE").Rate;

            ViewBag.SewerageRate = sewerageRate;
            return(View(SearchWaterViewModels));
        }
예제 #6
0
        public ActionResult FillSubCategory(string Category)
        {
            var    userid    = User.Identity.GetUserId();
            var    username  = User.Identity.GetUserName();
            string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Rate;
            ViewBag.NGASCode    = db.NGAS.ToList();
            SearchBillingAndCollectionRates searchBillingAndCollectionRates = new SearchBillingAndCollectionRates();

            if (!string.IsNullOrEmpty(Category))
            {
                searchBillingAndCollectionRates.BillingRate = db.BillingRates.Where(m => m.Category == Category).ToList();
                var bill   = db.BillingRates.Where(x => x.ZoneGroup == ZoneGroup).GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                var subcat = db.BillingRates.Where(x => x.ZoneGroup == ZoneGroup).Where(m => m.Category == Category).GroupBy(m => m.SubCategory).Select(g => new { SubCategory = g.Key }).ToList();

                foreach (var item in bill)
                {
                    searchBillingAndCollectionRates.Category.Add(item.Category);
                }

                foreach (var item in subcat)
                {
                    searchBillingAndCollectionRates.SubCategory.Add(item.SubCategory);
                }
            }
            ViewBag.ZoneGroup = ZoneGroup;
            ViewBag.Category  = Category;
            return(View("ViewBillingAndCollectionRates", searchBillingAndCollectionRates));
        }
        public ActionResult AddPeriod(DateTime DateFrom, DateTime DateTo, string PeriodText, string Groups)
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var    username           = User.Identity.GetUserName();
            var    userid             = User.Identity.GetUserId();
            string ZoneGroup          = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            var    maxBillingPeriodId = db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).Max(m => m.BillingPeriodId);
            var    EOMStatus          = db.BillingPeriod.FirstOrDefault(m => m.BillingPeriodId == maxBillingPeriodId).EOMStatus ?? "NOT DONE";

            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Period;
            string   previousStatus = "YES";
            DateTime?previousDateTo = null;

            EOMStatus = "DONE"; //Temporary code. To bypass EOM process before new billing period.
            if (EOMStatus.ToUpper() == "DONE")
            {
                if (db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).Count() > 0)
                {
                    var maxBillingId = db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).Max(m => m.BillingPeriodId);
                    previousStatus = db.BillingPeriod.Where(m => m.BillingPeriodId == maxBillingId).Where(m => m.groupCode == ZoneGroup).FirstOrDefault().Finalized;
                    previousDateTo = db.BillingPeriod.Where(m => m.BillingPeriodId == maxBillingId).Where(m => m.groupCode == ZoneGroup).FirstOrDefault().DateTo;
                }
                else
                {
                    previousDateTo = DateFrom.AddDays(-1);
                }

                if (previousStatus.ToUpper() == "YES")
                {
                    if (DateFrom > previousDateTo)
                    {
                        BillingPeriod PeriodAssignment = new BillingPeriod();
                        PeriodAssignment.PeriodText = PeriodText;
                        PeriodAssignment.DateFrom   = DateFrom;
                        PeriodAssignment.DateTo     = DateTo;
                        PeriodAssignment.groupCode  = ZoneGroup;
                        PeriodAssignment.Finalized  = "NO";
                        PeriodAssignment.Generated  = "NO";
                        db.BillingPeriod.Add(PeriodAssignment);
                        db.SaveChanges();
                    }
                    else
                    {
                        TempData["TransactionSuccess"] = "DatePeriodFailed";
                    }
                }
                else
                {
                    TempData["TransactionSuccess"] = "PeriodFailed";
                }
                SL.LogInfo(User.Identity.Name, Request.RawUrl, "Maintenance Period Table - Period Table Added  - from Terminal: " + ipaddress);
            }
            else
            {
                TempData["TransactionSuccess"] = "GenerateEOMFirst";
            }
            return(RedirectToAction("ViewPeriodTablePRG", "MaintenancePeriodTable"));
        }
        public ActionResult ViewPoleRentalsRPG()
        {
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole     = roleAssignmentMatrix.Pole;
            ViewBag.CompanySelected = "OK";
            SearchPoleInformationViewModel temp = TempData["SearchPoleRentalViewModels"] as SearchPoleInformationViewModel;

            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            TempData.Keep("SearchPoleRentalViewModels");
            return(View("ViewPoleRentals", temp));
        }
예제 #9
0
        public ActionResult ViewGarbagePRG()
        {
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole     = roleAssignmentMatrix.Garbage;
            ViewBag.CompanySelected = "OK";
            SearchGarbageInformation temp = TempData["GarbageData"] as SearchGarbageInformation;

            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            TempData.Keep("GarbageData");
            return(View("ViewGarbage", temp));
        }
예제 #10
0
        public async Task <ActionResult> Register(RegisterViewModel model, String Name)
        {
            BCS_Context db = new BCS_Context();

            if (ModelState.IsValid)
            {
                Encrypt encrypt = new Encrypt(model.Password);
                var     user    = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email, LastName = model.LastName, MiddleName = model.MiddleName, GivenName = model.GivenName, ZoneGroup = model.ZoneGroupCode, Status = model.Status, Division = model.Division, LocalPass = encrypt.EncryptedValue, Zone = model.Zone
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //Assign Role to user Here
                    await this.UserManager.AddToRoleAsync(user.Id, Name);

                    RoleAssignmentMatrix roleAssignmentMatrix = new RoleAssignmentMatrix();
                    roleAssignmentMatrix.UserName  = model.UserName;
                    roleAssignmentMatrix.ZoneGroup = model.ZoneGroupCode;
                    db.RoleAssignmentMatrix.Add(roleAssignmentMatrix);
                    await db.SaveChangesAsync();

                    //Ends Here
                    //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    //return RedirectToAction("Index", "Home");
                    TempData["TransactionSuccess"] = "Add";

                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "Account Registered - from Terminal: " + ipaddress);

                    return(RedirectToAction("ViewUser", "Account"));
                }

                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            ViewBag.ZoneGroupCode          = new SelectList(db.ZoneGroup.ToList(), "ZoneGroupCode", "ZoneGroupName");
            ViewBag.Name                   = new SelectList(context.Roles.ToList(), "Name", "Name");
            ViewBag.Division               = new SelectList(db.Division.ToList(), "Code", "Name");
            TempData["TransactionSuccess"] = "Failed";
            return(View(model));
        }
예제 #11
0
        //private ApplicationUserManager appmanager;
        public ActionResult ViewWaterPRG()
        {
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole     = roleAssignmentMatrix.Water;
            ViewBag.CompanySelected = "OK";

            ViewBag.ValidatePostback = "True"; //This line of code use for serverside validation.
            SearchWaterViewModel temp = TempData["WaterAssignmentData"] as SearchWaterViewModel;

            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            TempData.Keep("WaterAssignmentData");
            return(View("ViewWater", temp));
        }
예제 #12
0
        public ActionResult ViewRates(string SubCategory, string NGASCode)
        {
            var    userid    = User.Identity.GetUserId();
            var    username  = User.Identity.GetUserName();
            string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Rate;
            ViewBag.NGASCode    = NGASCode;
            List <BillingRate> BillingRates = new List <BillingRate>();

            BillingRates     = db.BillingRates.Where(x => x.ZoneGroup == ZoneGroup).Where(m => m.SubCategory == SubCategory).ToList();
            ViewBag.Category = db.BillingRates.Where(x => x.ZoneGroup == ZoneGroup).Where(m => m.SubCategory == SubCategory).FirstOrDefault().Category;
            return(View(BillingRates));
        }
예제 #13
0
        public ActionResult ViewRatesPRG()
        {
            var userid   = User.Identity.GetUserId();
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Rate;
            ViewBag.NGASCode    = TempData["NGASCode"] as string;
            List <BillingRate> temp = TempData["BillingRateList"] as List <BillingRate>;

            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            TempData.Keep("BillingRateList");
            ViewBag.Category = TempData["Category"] as string;
            return(View("ViewRates", temp));
        }
예제 #14
0
        // GET: BillingGenerate
        public ActionResult ViewGenerate()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            var    username  = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Billing;

            List <BillingPeriod> billingperiod = new List <BillingPeriod>();

            billingperiod = db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).OrderByDescending(m => m.BillingPeriodId).ToList();

            return(View(billingperiod));
        }
예제 #15
0
        public ActionResult ViewPassedOnBillingPRG()
        {
            PassedOnBillingViewModel PassedList = new PassedOnBillingViewModel();

            PassedList.ZoneList = db.Zone.Select(x => x).ToList();
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole     = roleAssignmentMatrix.PassedOnBilling;
            ViewBag.CompanySelected = "OK";
            PassedOnBillingViewModel temp = TempData["PassedOnBillingData"] as PassedOnBillingViewModel;

            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            TempData.Keep("PassedOnBillingData");
            return(View("ViewPassedOnBilling", temp));
        }
        public ActionResult ViewPoleRentals(string SearchInput, FormCollection frm)
        {
            var userid   = User.Identity.GetUserId();
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Pole;

            //Result of initial search button
            if (!string.IsNullOrEmpty(SearchInput))
            {
                SearchPoleInformationViewModel searchcompany1 = new SearchPoleInformationViewModel();
                ApplicationDbContext           context        = new ApplicationDbContext();
                string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;

                List <Company> NewCompanies = new List <Company>();
                NewCompanies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + SearchInput + "%'").ToList();
                SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                searchcompany1.CompanyList = searchCompanyPerGroup.Companies;

                //searchcompany1.SearchInput = SearchInput.ToString();
                //searchcompany1.CompanyList = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + SearchInput + "%'").ToList();
                return(View(searchcompany1));
            }
            //Result of selected company shown by "Search button"
            else if (frm.Count == 2)
            {
                int  OutParseValue;
                bool CanParse = int.TryParse(frm[1].ToString(), out OutParseValue);
                SearchPoleInformationViewModel searchcompany1 = new SearchPoleInformationViewModel();

                if (CanParse)
                {
                    int ParsedCompanyID = int.Parse(frm[1].ToString());
                    searchcompany1.PoleInformationList = db.PoleInformation.Where(m => m.CompanyId == ParsedCompanyID).ToList();
                    searchcompany1.CompanyList         = db.Company.Where(m => m.CompanyID == ParsedCompanyID).ToList();
                    ViewBag.CompanySelected            = "OK";
                }
                return(View(searchcompany1));
            }
            //Default value
            else
            {
                SearchPoleInformationViewModel searchcompany1 = new SearchPoleInformationViewModel();
                return(View(searchcompany1));
            }
        }
예제 #17
0
        public ActionResult ViewBillingAndCollectionRatesRPG()
        {
            var    username  = User.Identity.GetUserName();
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;

            ViewBag.ZoneGroup = ZoneGroup;
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Rate;
            ViewBag.NGASCode    = db.NGAS.ToList();
            SearchBillingAndCollectionRates temp = TempData["searchBillingAndCollectionRates"] as SearchBillingAndCollectionRates;

            ViewBag.Category           = TempData["Category"] as string;
            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            TempData.Keep("searchBillingAndCollectionRates");
            return(View("ViewBillingAndCollectionRates", temp));
        }
예제 #18
0
        public ActionResult LoadFranchiseInformation(int?CompanyId)
        {
            var userid   = User.Identity.GetUserId();
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Franchise;

            SearchFranchiseViewModel SearchFranchiseViewModels = new SearchFranchiseViewModel();

            if (CompanyId != null)
            {
                SearchFranchiseViewModels.Companies = db.Company.Where(m => m.CompanyID == CompanyId).ToList();
                SearchFranchiseViewModels.FranchiseFeeInformations = db.FranchiseFeeInformation.Where(m => m.CompanyId == CompanyId).ToList();
                ViewBag.CompanySelected = "OK";
            }
            SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Franchise - Search Franchise Information  - from Terminal: " + ipaddress);
            return(View("ViewFranchise", SearchFranchiseViewModels));
        }
        public ActionResult ViewPeriodTablePRG(FormCollection frm)
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var    userid    = User.Identity.GetUserId();
            var    username  = User.Identity.GetUserName();
            string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Period;
            //ViewBag.Groups = new SelectList(db.ZoneGroup.ToList(), "ZoneGroupCode", "ZoneGroupName");

            SearchBillingPeriodViewModel SearchPeriodViewModels = new SearchBillingPeriodViewModel();

            //SearchPeriodViewModels.BillPeriodList = db.BillingPeriod.ToList();
            SearchPeriodViewModels.BillPeriodList = db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).OrderByDescending(n => n.DateFrom).ToList();
            //return View(SearchPeriodViewModels);
            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            return(View("ViewPeriodTable", SearchPeriodViewModels));
        }
예제 #20
0
        public ActionResult EditCategory(string EditCategory, string Category)
        {
            var    userid    = User.Identity.GetUserId();
            var    username  = User.Identity.GetUserName();
            string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            RoleAssignmentMatrix            roleAssignmentMatrix            = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);
            SearchBillingAndCollectionRates searchBillingAndCollectionRates = new SearchBillingAndCollectionRates();

            ViewBag.IsValidRole = roleAssignmentMatrix.Rate;
            ViewBag.Groups      = db.ZoneGroup.ToList();

            if (!string.IsNullOrEmpty(Category))
            {
                db.Database.ExecuteSqlCommand("Update BillingRates set Category = '" + Category + "' where Category = '" + EditCategory + "'");
                searchBillingAndCollectionRates.BillingRate = db.BillingRates.Where(x => x.ZoneGroup == ZoneGroup).Where(m => m.Category == Category).ToList();
                ViewBag.Category = Category;
                TempData["TransactionSuccess"] = "Edit";
            }
            else
            {
                ViewBag.ShowAdd = false;
                Response.Write("<script>alert('Unable to edit Category. Please check blank field.')</script>");
            }

            var bill   = db.BillingRates.Where(x => x.ZoneGroup == ZoneGroup).GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
            var subcat = db.BillingRates.Where(x => x.ZoneGroup == ZoneGroup).Where(m => m.Category == Category).GroupBy(m => m.SubCategory).Select(g => new { SubCategory = g.Key }).ToList();

            foreach (var item in bill)
            {
                searchBillingAndCollectionRates.Category.Add(item.Category);
            }

            foreach (var item in subcat)
            {
                searchBillingAndCollectionRates.SubCategory.Add(item.SubCategory);
            }

            TempData["searchBillingAndCollectionRates"] = searchBillingAndCollectionRates;
            TempData["Category"] = Category;
            return(RedirectToAction("ViewBillingAndCollectionRatesRPG", "MaintenanceBillingAndCollectionRates"));
            //return View("ViewBillingAndCollectionRates", searchBillingAndCollectionRates);
        }
예제 #21
0
        public ActionResult ViewGeneratePRG()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            var    username  = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Billing;

            List <BillingPeriod> billingperiod = new List <BillingPeriod>();

            billingperiod = db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).OrderByDescending(m => m.BillingPeriodId).ToList();

            //if(TempData["BillingStatus"] != null)
            //    Response.Write("<script>alert('" + TempData["BillingStatus"].ToString() + "')</script>");
            ViewBag.BillingStatus = TempData["BillingStatus"] as string;
            ViewBag.Toggled       = TempData["Toggled"] as string;
            return(View("ViewGenerate", billingperiod));
        }
예제 #22
0
        public ActionResult ViewWaterAssignment(int?CompanyID)
        {
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            var    username  = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Water;

            SearchWaterViewModel SearchWaterViewModels = new SearchWaterViewModel();

            if (CompanyID != null)
            {
                SearchWaterViewModels.Companies             = db.Company.Where(m => m.CompanyID == CompanyID).ToList();
                SearchWaterViewModels.BillingPeriods        = BillingPeriods();
                SearchWaterViewModels.WaterMeterAssignments = db.WaterMeterAssignment.Where(m => m.CompanyId == CompanyID).ToList();
                ViewBag.CompanySelected = "OK";
            }
            SearchWaterViewModels.BillingPeriods = BillingPeriods();
            return(View("ViewWater", SearchWaterViewModels));
        }
예제 #23
0
        public ActionResult Edit_Post(RoleAssignmentMatrix roleAssignmentMatrix, string All, string user2)
        {
            roleAssignmentMatrix.UserName = user2;
            ApplicationDbContext context = new ApplicationDbContext();
            string zonegroup             = context.Users.FirstOrDefault(m => m.UserName == roleAssignmentMatrix.UserName).ZoneGroup;

            roleAssignmentMatrix.ZoneGroup = zonegroup;
            TryUpdateModel(roleAssignmentMatrix);
            roleAssignmentMatrix.ZoneGroup = zonegroup;

            if (All == "All")
            {
                roleAssignmentMatrix.Administrative   = true;
                roleAssignmentMatrix.Aging            = true;
                roleAssignmentMatrix.Billing          = true;
                roleAssignmentMatrix.Collection       = true;
                roleAssignmentMatrix.Company          = true;
                roleAssignmentMatrix.Franchise        = true;
                roleAssignmentMatrix.Garbage          = true;
                roleAssignmentMatrix.HO               = true;
                roleAssignmentMatrix.JBR              = true;
                roleAssignmentMatrix.PassedOnBilling  = true;
                roleAssignmentMatrix.Payment          = true;
                roleAssignmentMatrix.Period           = true;
                roleAssignmentMatrix.Pole             = true;
                roleAssignmentMatrix.Rate             = true;
                roleAssignmentMatrix.Rentals          = true;
                roleAssignmentMatrix.Security         = true;
                roleAssignmentMatrix.Sewerage         = true;
                roleAssignmentMatrix.SubsidiaryLedger = true;
                roleAssignmentMatrix.Water            = true;
            }

            db.Entry(roleAssignmentMatrix).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            TempData["TransactionSuccess"] = "Edit";
            SL.LogInfo(User.Identity.Name, Request.RawUrl, "Role Assignment - Role Edited  - from Terminal: " + ipaddress);
            return(RedirectToAction("Details"));
        }
예제 #24
0
        public ActionResult DisplayPassedOnBilling(int CompId, FormCollection frmcollection)
        {
            PassedOnBillingViewModel searchcompany = new PassedOnBillingViewModel();

            searchcompany.ZoneList = db.Zone.Select(x => x).ToList();
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            var    username  = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.PassedOnBilling;
            PassedOnBillingViewModel SearchCompanyViewModels = new PassedOnBillingViewModel();

            if (frmcollection.Count == 0)
            {
                SearchCompanyViewModels.PassedOnBillingList = db.PassedOnBillingInformation.SqlQuery("Select * from SecurityGuardFeeInformations where CompanyId = '" + frmcollection["CompanyId"] + "'").ToList();
                SearchCompanyViewModels.TotalAmount         = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompId).Sum(x => x.Amount);
                return(View(SearchCompanyViewModels));
            }
            else if (frmcollection.Count >= 1)
            {
                PassedOnBillingViewModel passedonBillingViewModels = new PassedOnBillingViewModel();
                int parsedID = int.Parse(frmcollection["PassedOnBillingInformationId"]);
                PassedOnBillingInformation securityfee = db.PassedOnBillingInformation.Find(parsedID);
                //db.PassedOnBillingInformation.Remove(securityfee);
                //db.SaveChanges();
                passedonBillingViewModels.CompanyList         = db.Company.Where(m => m.CompanyID == CompId).ToList();
                passedonBillingViewModels.PassedOnBillingList = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompId).ToList();
                passedonBillingViewModels.TotalAmount         = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompId).Sum(x => x.Amount);
                return(View("ViewPassedOnBilling", passedonBillingViewModels));
            }
            ViewBag.CompanySelected = "OK";
            //SearchCompanyViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).Where(m => m.Finalized.ToUpper() != "YES").ToList();
            SearchCompanyViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).ToList();
            var billp = SearchCompanyViewModels.BillingPeriodList.OrderByDescending(m => m.BillingPeriodId);

            SearchCompanyViewModels.BillingPeriodList = billp.ToList();
            return(View());
        }
        public ActionResult UpdatePeriod(FormCollection frmcollection)
        {
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Period;
            BillingPeriod Periodinfo  = null;
            int           ParsedIntID = int.Parse(frmcollection["BillingPeriodId"]);

            string BillingStatus = db.BillingPeriod.Where(m => m.BillingPeriodId == ParsedIntID).SingleOrDefault().Finalized;

            if (BillingStatus.ToUpper() == "NO")
            {
                Periodinfo = db.BillingPeriod.Find(ParsedIntID);
                if (Periodinfo != null)
                {
                    Periodinfo.PeriodText = frmcollection["PeriodText"].ToString();
                    Periodinfo.DateFrom   = Convert.ToDateTime(frmcollection["DateFrom"].ToString());
                    Periodinfo.DateTo     = Convert.ToDateTime(frmcollection["DateTo"].ToString());
                    //Periodinfo.groupCode = Group;
                    db.Entry(Periodinfo).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    throw new Exception("Invalid transaction.");
                }
            }
            else
            {
                Response.Write("<script>alert('Unable to edit finalized billing period.')</script>");
            }
            int parsedID = int.Parse(frmcollection["BillingPeriodId"]);

            SL.LogInfo(User.Identity.Name, Request.RawUrl, "Maintenance Period Table - Period Table Updated  - from Terminal: " + ipaddress);

            return(RedirectToAction("ViewPeriodTablePRG", "MaintenancePeriodTable"));
        }
예제 #26
0
        public ActionResult ViewGenerate(FormCollection frm)
        {
            int    generatePerCompanyId  = 0;
            string BillingGenerateValue  = "";
            ApplicationDbContext context = new ApplicationDbContext();
            var    userid     = User.Identity.GetUserId();
            var    username   = User.Identity.GetUserName();
            string ZoneGroup1 = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.SingleOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Billing;

            //CoverageFrom CoverageTo
            int billingPeriodId = int.Parse(frm["PeriodId"].ToString());

            VerifyBillingPeriod verify = new VerifyBillingPeriod(billingPeriodId, ZoneGroup1);

            if (verify.canGenerate()) //Verify if previous billing already generated a billing.
            {
                string   FxRate         = frm["FxRate"].ToString();
                DateTime dtCoverageFrom = Convert.ToDateTime(frm["CoverageFrom"].ToString());
                DateTime dtCoverageTo   = Convert.ToDateTime(frm["CoverageTo"].ToString());
                DateTime dtBillingDate  = Convert.ToDateTime(frm["BillDate"].ToString());
                DateTime dtBillingDue   = Convert.ToDateTime(frm["DueDate"].ToString());
                Company  company        = new Company();

                string TypeOfBillingGenerate = frm["TypeOfBillingGenerate"].ToString();

                if (TypeOfBillingGenerate == "PerCompany")
                {
                    generatePerCompanyId = Convert.ToInt32(frm["generatePerCompanyId"].ToString());
                    BillingGenerateValue = frm["TypeOfBillingGeneratePerCompany"].ToString();
                }
                else if (TypeOfBillingGenerate == "PerPOB")
                {
                    BillingGenerateValue = frm["TypeOfBillingGeneratePerPOB"].ToString();
                }
                else if (TypeOfBillingGenerate == "PerBillingType")
                {
                    BillingGenerateValue = frm["TypeOfBillingGeneratePerBillingType"].ToString();
                }
                else if (TypeOfBillingGenerate == "PerAdminFee")
                {
                    BillingGenerateValue = frm["TypeOfBillingGeneratePerAdminFee"].ToString();
                }


                //Get the current user
                //ApplicationDbContext context = new ApplicationDbContext();
                string        ZoneGroup     = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
                BillingPeriod billingPeriod = db.BillingPeriod.Find(billingPeriodId);
                string        isgenerated   = billingPeriod.Generated;
                bool          isGenerated   = true; // delete this line of need to delete first the records in regenerate
                //bool isGenerated = false; //The role is Delete first the data then return as true.
                #region delete_records
                //08-01-2017 do not delete records in regenerate.. update only the changes
                //if (isgenerated.ToLower() == "yes")
                //{
                //    if (!string.IsNullOrEmpty(TypeOfBillingGenerate) && TypeOfBillingGenerate.ToUpper() == "PERCOMPANY") //Delete base on type of billing generate
                //    {
                //        int companyId = Convert.ToInt32(generatePerCompanyId);
                //        BillingRegenerateBLL billingRegenerateBLL = new BillingRegenerateBLL(billingPeriodId, companyId);
                //        isGenerated = billingRegenerateBLL.RegenerateBillingPerCompany();
                //        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Regenerate- Billing generate percompany.  - from Terminal: " + ipaddress);
                //    }
                //    else if (!string.IsNullOrEmpty(TypeOfBillingGenerate) && TypeOfBillingGenerate.ToUpper() == "PERENTERPRISE")
                //    {
                //        BillingRegenerateBLL billingRegenerateBLL = new BillingRegenerateBLL(billingPeriodId, BillingGenerateValue);
                //        isGenerated = billingRegenerateBLL.RegenerateBillingPerEnterprise();
                //        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Regenerate- Billing generate perenterprise.  - from Terminal: " + ipaddress);
                //    }
                //    else if (!string.IsNullOrEmpty(TypeOfBillingGenerate) && TypeOfBillingGenerate.ToUpper() == "PERBILLINGTYPE")
                //    {
                //        BillingRegenerateBLL billingRegenerateBLL = new BillingRegenerateBLL(billingPeriodId, BillingGenerateValue);
                //        isGenerated = billingRegenerateBLL.RegenerateBillingPerBillingType();
                //        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Regenerate- Billing generate perbillingtype.  - from Terminal: " + ipaddress);
                //    }
                //    else if (!string.IsNullOrEmpty(TypeOfBillingGenerate) && TypeOfBillingGenerate.ToUpper() == "PERADMINFEE")
                //    {
                //        BillingRegenerateBLL billingRegenerateBLL = new BillingRegenerateBLL(billingPeriodId, BillingGenerateValue);
                //        isGenerated = billingRegenerateBLL.RegenerateBillingPerAdminFee();
                //        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Regenerate- Billing generate peradminfee.  - from Terminal: " + ipaddress);
                //    }
                //    else
                //    {
                //        BillingRegenerateBLL billingRegenerateBLL = new BillingRegenerateBLL(billingPeriodId);
                //        isGenerated = billingRegenerateBLL.RegenerateBilling();
                //        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Regenerate- Billing generate all company.  - from Terminal: " + ipaddress);
                //    }
                //}
                #endregion delete_records
                //BillingBusinessLayer billingBusinessLayer = new BillingBusinessLayer(ZoneGroup, dtCoverageFrom, dtCoverageTo, dtBillingDate, dtBillingDue, billingPeriodId, userid, FxRate, generatePerCompanyId, TypeOfBillingGenerate);
                BillingBusinessLayerNewAlgo billingBusinessLayerNewAlgoTemp = new BillingBusinessLayerNewAlgo(ZoneGroup, dtCoverageFrom, dtCoverageTo, dtBillingDate, dtBillingDue, billingPeriodId, userid, FxRate, generatePerCompanyId, TypeOfBillingGenerate, BillingGenerateValue);

                //bool isCurrencyValid = true;
                bool isCurrencyValid = billingBusinessLayerNewAlgoTemp.isValidFxRate(FxRate);
                if (dtBillingDue >= dtCoverageFrom && dtBillingDate >= dtCoverageFrom)
                {
                    if (db.BillingRates.Any(m => m.Category == "Sewerage" && m.ZoneGroup == ZoneGroup))
                    {
                        if (isCurrencyValid)
                        {
                            BillingPeriod CloseBillingPeriod = db.BillingPeriod.Find(billingPeriodId);
                            CloseBillingPeriod.IsPaymentOpen   = false;
                            db.Entry(CloseBillingPeriod).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                            using (var dbtransaction = db.Database.BeginTransaction())
                            {
                                try //If Custom error is Enabled. Delete this try catch block.. "Using" statement above will automatically rollback transaction when error occur.
                                {
                                    if (isgenerated.ToLower() == "yes" && isGenerated)
                                    {
                                        //BillingBusinessLayerNewAlgo billingBusinessLayerNewAlgo = new BillingBusinessLayerNewAlgo(ZoneGroup, dtCoverageFrom, dtCoverageTo, dtBillingDate, dtBillingDue, billingPeriodId, userid, FxRate, generatePerCompanyId, TypeOfBillingGenerate, BillingGenerateValue);
                                        //billingBusinessLayer.generateBilling();
                                        billingBusinessLayerNewAlgoTemp.generateBilling();
                                        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Regenerate - Billing generate complete.  - from Terminal: " + ipaddress);
                                        TempData["BillingStatus"] = "Billing generate complete";//Response.Write("<script>alert('Billing generate complete.')</script>");
                                    }
                                    else
                                    {
                                        //BillingBusinessLayerNewAlgo billingBusinessLayerNewAlgo = new BillingBusinessLayerNewAlgo(ZoneGroup, dtCoverageFrom, dtCoverageTo, dtBillingDate, dtBillingDue, billingPeriodId, userid, FxRate, generatePerCompanyId, TypeOfBillingGenerate, BillingGenerateValue);
                                        //billingBusinessLayer.generateBilling();
                                        billingBusinessLayerNewAlgoTemp.generateBilling();
                                        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Generate- Billing generate complete.  - from Terminal: " + ipaddress);
                                        TempData["BillingStatus"] = "Billing generate complete"; //Response.Write("<script>alert('Billing generate complete.')</script>");
                                    }
                                }
                                catch (DbEntityValidationException ex)
                                {
                                    //    catch (DbEntityValidationException dbEx)
                                    //{
                                    foreach (var validationErrors in ex.EntityValidationErrors)
                                    {
                                        foreach (var validationError in validationErrors.ValidationErrors)
                                        {
                                            Trace.TraceInformation("Property: {0} Error: {1}",
                                                                   validationError.PropertyName,
                                                                   validationError.ErrorMessage);
                                        }
                                        //    }
                                    }

                                    string ex1 = ex.Message;
                                    TempData["BillingStatus"] = ex1;  //Response.Write("<script>alert('Billing Generation failed.')</script>");
                                    dbtransaction.Rollback();
                                }
                            }//End of using
                             //BillingPeriod OpenBillingPeriod = db.BillingPeriod.Find(billingPeriodId);
                             //OpenBillingPeriod.IsPaymentOpen = true;
                             //db.Entry(OpenBillingPeriod).State = System.Data.Entity.EntityState.Modified;
                             //db.SaveChanges();
                        }//End of is not USD
                        else
                        {
                            TempData["BillingStatus"] = "Billing Generation failed. The system has detected USD type of billing. Please input data in FX Rate field.";
                            SL.LogWarning(User.Identity.Name, Request.RawUrl, "Billing Generate- Billing Generation failed.  - from Terminal: " + ipaddress);
                            //Response.Write("<script>alert('Billing Generation failed. The system has detected USD type of billing. Please input data in FX Rate field.')</script>");
                        }
                    }
                    else
                    {
                        TempData["BillingStatus"] = "Unable to proceed. No Sewerage rate detected.";
                        SL.LogError(User.Identity.Name, Request.RawUrl, "Billing Generate- Unable to proceed.No Sewerage rate detected.  - from Terminal: " + ipaddress);


                        //Response.Write("<script>alert('Unable to proceed. No Sewerage rate detected.')</script>");
                    }
                }
                else
                {
                    TempData["BillingStatus"] = "Unable to proceed. Billing Date/Due Date must be greater than Coverage Date.";
                }
            }
            else
            {
                TempData["BillingStatus"] = "Unable to proceed. Previous billing period already generated a billing.";
                //Response.Write("<script>alert('Unable to proceed. Previous billing period already generated a billing.')</script>");
            }
            //
            List <BillingPeriod> billingperiodlist = new List <BillingPeriod>();
            billingperiodlist = db.BillingPeriod.ToList();
            //return View("ViewGenerate", billingperiodlist);
            TempData["Toggled"] = "Toggled";
            return(RedirectToAction("ViewGeneratePRG", "BillingGenerate"));
        }
예제 #27
0
        public ActionResult Edit(int id)
        {
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.Find(id);

            return(View(roleAssignmentMatrix));
        }
        public ActionResult AddPoleRental(FormCollection frm)
        {
            var origamt = frm["Amount"];
            var amt     = frm["Amount"].Split(',');

            var newAmount = "";

            foreach (var item in amt)
            {
                newAmount += item;
            }
            var userid   = User.Identity.GetUserId();
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Pole;
            //SL.LogInfo(User.Identity.Name, Request.RawUrl, "User Added Item! (Data Entry Pole Rental) - from Terminal:" + ipaddress);
            string isEdit = frm["isEdit"].ToString();
            SearchPoleInformationViewModel SearchPoleRentalViewModels = new SearchPoleInformationViewModel();

            PoleInformation PoleRentalAssignment = new PoleInformation();
            int             CompanyId            = int.Parse(frm["CompanyId"].ToString());
            var             errors = ModelState.Values.SelectMany(v => v.Errors);

            TryUpdateModel(PoleRentalAssignment);
            //if (ModelState.IsValid)
            //{
            if (isEdit != "True")
            {
                PoleRentalAssignment.Amount        = Convert.ToDecimal(origamt);
                PoleRentalAssignment.CreatedDate   = DateTime.Now;
                PoleRentalAssignment.CreatedBy     = userid;
                PoleRentalAssignment.BillMode      = frm["BillMode"];
                PoleRentalAssignment.BillingMonths = frm["billingMonths"];
                //PoleRentalAssignment.BillingMonths = "1,2,3,4,5,6,7,8,9,10,11,12";
                db.PoleInformation.Add(PoleRentalAssignment);
                db.SaveChanges();
                TempData["TransactionSuccess"] = "Add";
                SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Pole Rental- Add  - from Terminal:" + ipaddress);
            }
            else
            {
                int ParsedIntID = int.Parse(frm["ID"]);
                PoleRentalAssignment = db.PoleInformation.Find(ParsedIntID);
                //compinfo.CompanyCode = frmcollection["CompanyCode"].ToString();
                PoleRentalAssignment.Amount        = Convert.ToDecimal(newAmount);
                PoleRentalAssignment.StartDate     = Convert.ToDateTime(frm["StartDate"].ToString());
                PoleRentalAssignment.EndDate       = Convert.ToDateTime(frm["EndDate"].ToString());
                PoleRentalAssignment.UpdateDate    = DateTime.Now;
                PoleRentalAssignment.UpdatedBy     = userid;
                PoleRentalAssignment.BillingMonths = frm["billingMonths"];
                //PoleRentalAssignment.BillingMonths = "1,2,3,4,5,6,7,8,9,10,11,12";
                PoleRentalAssignment.BillMode        = frm["BillMode"];
                db.Entry(PoleRentalAssignment).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                TempData["TransactionSuccess"] = "Edit";
                SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Pole Rental- Edit  - from Terminal:" + ipaddress);
                //ViewBag.TransactionSuccess = "Add";
            }
            ViewBag.ValidatePostback = "True";
            //}
            //else
            //{
            //    ViewBag.ValidatePostback = "False";
            //}

            ViewBag.CompanySelected = "OK";
            SearchPoleRentalViewModels.CompanyList         = db.Company.Where(m => m.CompanyID == CompanyId).ToList();
            SearchPoleRentalViewModels.PoleInformationList = db.PoleInformation.Where(m => m.CompanyId == CompanyId).ToList();

            TempData["SearchPoleRentalViewModels"] = SearchPoleRentalViewModels;
            return(RedirectToAction("ViewPoleRentalsRPG", "DataEntryPoleRental"));
            //return View("ViewPoleRentals", SearchPoleRentalViewModels);
        }
예제 #29
0
        public ActionResult ViewPassedOnBilling(string SearchInput, FormCollection frm)
        {
            var    userid    = User.Identity.GetUserId();
            var    username  = User.Identity.GetUserName();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.PassedOnBilling;

            //Result of initial search button
            if (!string.IsNullOrEmpty(SearchInput))
            {
                PassedOnBillingViewModel searchcompany1 = new PassedOnBillingViewModel();
                searchcompany1.ZoneList = db.Zone.Select(x => x).ToList();
                ApplicationDbContext context = new ApplicationDbContext();

                List <Company> NewCompanies = new List <Company>();
                NewCompanies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + SearchInput + "%'").ToList();
                SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                searchcompany1.CompanyList = searchCompanyPerGroup.Companies;
                //searchcompany1.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).Where(m => m.Finalized.ToUpper() != "YES").ToList();
                searchcompany1.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).ToList();
                var billp = searchcompany1.BillingPeriodList.OrderByDescending(m => m.BillingPeriodId);
                searchcompany1.BillingPeriodList = billp.ToList();

                return(View(searchcompany1));
            }
            //Result of selected company shown by "Search button"
            else if (frm.Count == 2)
            {
                int  OutParseValue;
                bool CanParse = int.TryParse(frm[1].ToString(), out OutParseValue);
                PassedOnBillingViewModel searchcompany1 = new PassedOnBillingViewModel();
                searchcompany1.ZoneList = db.Zone.Select(x => x).ToList();
                if (CanParse)
                {
                    int ParsedCompanyID = int.Parse(frm[1].ToString());
                    searchcompany1.PassedOnBillingList = db.PassedOnBillingInformation.Where(m => m.CompanyId == ParsedCompanyID).ToList();
                    searchcompany1.CompanyList         = db.Company.Where(m => m.CompanyID == ParsedCompanyID).ToList();
                    if (searchcompany1.PassedOnBillingList.Count >= 1)
                    {
                        searchcompany1.TotalAmount = searchcompany1.PassedOnBillingList.Sum(x => x.Amount);
                    }
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Passed OnBilling - Search Company -from Terminal:" + ipaddress);
                    ViewBag.CompanySelected = "OK";
                }
                //searchcompany1.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).Where(m => m.Finalized.ToUpper() != "YES").ToList();
                searchcompany1.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).ToList();
                var billp = searchcompany1.BillingPeriodList.OrderByDescending(m => m.BillingPeriodId);
                searchcompany1.BillingPeriodList = billp.ToList();
                return(View(searchcompany1));
            }
            //Default value
            else
            {
                PassedOnBillingViewModel searchcompany1 = new PassedOnBillingViewModel();
                searchcompany1.ZoneList = db.Zone.Select(x => x).ToList();
                //searchcompany1.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).Where(m => m.Finalized.ToUpper() != "YES").ToList();
                searchcompany1.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).ToList();
                var billp = searchcompany1.BillingPeriodList.OrderByDescending(m => m.BillingPeriodId);
                searchcompany1.BillingPeriodList = billp.ToList();
                return(View(searchcompany1));
            }
        }
예제 #30
0
        public ActionResult AddGarbage(FormCollection frm)
        {
            string isEdit    = frm["isEdit"].ToString();
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            var    username  = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Garbage;
            SL.LogInfo(User.Identity.Name, Request.RawUrl, "User Added Item! (Data Entry Garbage) - from Terminal:" + ipaddress);
            GarbageInformation garbageInformation = new GarbageInformation();
            int CompanyId = int.Parse(frm["CompanyId"].ToString());

            TryUpdateModel(garbageInformation);
            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                DateTime CollectionDate = DateTime.Parse(frm["CollectionDate"].ToString());
                int      BillingPeriod  = int.Parse(frm["BillingPeriod"].ToString());
                string   Type           = frm["Type"].ToString();
                decimal  Rate           = decimal.Parse(frm["Rate"].ToString());
                decimal  Weight         = decimal.Parse(frm["Weight"].ToString());

                if (isEdit != "Edit")
                {
                    VerifyDuplicateEntries verifyDuplicateEntries = new VerifyDuplicateEntries(CompanyId, BillingPeriod, "GARBAGE");
                    if (!verifyDuplicateEntries.hasDuplicateByBillingPeriod())
                    {
                        //garbageInformation.CompanyId = CompanyId;
                        //garbageInformation.BillingPeriod = BillingPeriod;
                        //garbageInformation.Type = Type;
                        //garbageInformation.Weight = Weight;
                        //garbageInformation.Rate = Rate;
                        //garbageInformation.CreatedBy = userid;
                        //garbageInformation.CreateDate = DateTime.Now;
                        //garbageInformation.CollectionDate = CollectionDate;

                        //db.GarbageInformations.Add(garbageInformation);
                        //db.SaveChanges();

                        db.Database.ExecuteSqlCommand("Insert into GarbageInformations(CompanyId,BillingPeriod,Type,Weight,Rate,CreatedBy,CreateDate,CollectionDate) values('" + CompanyId + "','" + BillingPeriod + "','" + Type + "','" + Weight + "','" + Rate + "','" + userid + "','" + DateTime.Now + "','" + CollectionDate + "')");
                        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Garbage - Add  - from Terminal:" + ipaddress);
                        TempData["TransactionSuccess"] = "Add";
                    }
                    else
                    {
                        TempData["TransactionSuccess"] = "DuplicateBillingPeriod";
                        SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Garbage Billing - Period already used  - from Terminal:" + ipaddress);
                    }
                }
                else
                {
                    int GarbageInformationId = int.Parse(frm["GarbageInfoId"].ToString());
                    //garbageInformation = db.GarbageInformations.Where(m => m.GarbageInformationId == GarbageInformationId).Single();
                    //garbageInformation.BillingPeriod = BillingPeriod;
                    //garbageInformation.Type = Type;
                    //garbageInformation.Rate = Rate;
                    //garbageInformation.Weight = Weight;
                    //garbageInformation.CollectionDate = CollectionDate;
                    //garbageInformation.UpdatedBy = userid;
                    //garbageInformation.UpdateDate = DateTime.Now;

                    //db.Entry(garbageInformation).State = System.Data.Entity.EntityState.Modified;
                    //db.SaveChanges();

                    db.Database.ExecuteSqlCommand("Update GarbageInformations set CompanyId = '" + CompanyId + "',BillingPeriod ='" + BillingPeriod + "',Type ='" + Type + "',Weight='" + Weight + "',Rate='" + Rate + "',UpdatedBy='" + userid + "',UpdateDate='" + DateTime.Now + "',CollectionDate='" + CollectionDate + "' where GarbageInformationId = '" + GarbageInformationId + "'");

                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Garbage - Edit - from Terminal:" + ipaddress);
                    TempData["TransactionSuccess"] = "Edit";
                }
            }

            SearchGarbageInformation searchGarbageInformation = new SearchGarbageInformation();

            searchGarbageInformation.Companies = db.Company.Where(m => m.CompanyID == CompanyId).ToList();
            //searchGarbageInformation.BillingPeriods = db.BillingPeriod.Where(m => m.Finalized == "No").Where(m => m.groupCode == ZoneGroup).ToList();
            IEnumerable <BillingPeriod> IBillingPeriods = db.BillingPeriod.Where(m => m.groupCode == ZoneGroup).ToList();

            searchGarbageInformation.BillingPeriods      = IBillingPeriods.OrderByDescending(m => m.BillingPeriodId).ToList();
            searchGarbageInformation.BillingRates        = db.BillingRates.Where(m => m.Category == "Garbage Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList();
            searchGarbageInformation.GarbageInformations = db.GarbageInformations.Where(m => m.CompanyId == CompanyId).ToList();

            var subcat1 = searchGarbageInformation.BillingRates.GroupBy(m => m.SubCategory).ToList();

            foreach (var item in subcat1)
            {
                searchGarbageInformation.SubCategory.Add(item.Key.ToString());
            }
            //return View("ViewGarbage", searchGarbageInformation);
            TempData["GarbageData"] = searchGarbageInformation;
            return(RedirectToAction("ViewGarbagePRG", "DataEntryGarbage"));
        }