public ActionResult ViewCompany() { ApplicationDbContext context = new ApplicationDbContext(); List <Company> NewCompanies = new List <Company>(); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; int SingleZoneGroupId = db.ZoneGroup.FirstOrDefault(d => d.ZoneGroupCode == ZoneGroup).ZoneGroupId; ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string; ViewBag.SelectedCompany = TempData["SelectedCompany"] as string; SearchCompany temp = TempData["searchcompany"] as SearchCompany; SearchCompany SearchCompanyViewModels = new SearchCompany(); NewCompanies = db.Company.Select(x => x).OrderBy(x => x.CompanyName).Take(10).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); if (ViewBag.SelectedCompany == null) { return(View(SearchCompanyViewModels)); } else { return(View("ViewCompany", temp)); } }
public PartialViewResult GetCompanies(string CompanyName) { ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup; List <Company> NewCompanies = new List <Company>(); List <Company> NewCompaniesPerGroup = new List <Company>(); NewCompanies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + CompanyName + "%'").ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); NewCompaniesPerGroup = searchCompanyPerGroup.Companies; return(PartialView("_BillingSearchCompany", NewCompaniesPerGroup)); }
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)); } }
// GET: DataEntryFranchise public ActionResult ViewFranchise(string CompanyName) { SearchFranchiseViewModel SearchFranchiseViewModels = new SearchFranchiseViewModel(); if (!string.IsNullOrEmpty(CompanyName)) { ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); 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 '%" + CompanyName + "%'").ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchFranchiseViewModels.Companies = searchCompanyPerGroup.Companies; //SearchFranchiseViewModels.Companies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + CompanyName + "%'").ToList(); } SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Franchise - Search Company - from Terminal: " + ipaddress); return(View(SearchFranchiseViewModels)); }
public ActionResult SearchEnterprise(string CompanyName) { SearchGarbageInformation searchGarbageInformation = new SearchGarbageInformation(); if (!string.IsNullOrEmpty(CompanyName)) { ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); 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 '%" + CompanyName + "%'").ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); searchGarbageInformation.Companies = searchCompanyPerGroup.Companies; SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Garbage - Search Company - from Terminal:" + ipaddress); //searchGarbageInformation.Companies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + CompanyName + "%'").ToList(); } return(View("ViewGarbage", searchGarbageInformation)); }
public ActionResult ViewWater(string ReturnedId) { SearchWaterViewModel SearchWaterViewModels = new SearchWaterViewModel(); if (!string.IsNullOrEmpty(ReturnedId)) { var userid = User.Identity.GetUserId(); 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 '%" + ReturnedId + "%'").ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchWaterViewModels.BillingPeriods = BillingPeriods(); SearchWaterViewModels.Companies = searchCompanyPerGroup.Companies; //SearchWaterViewModels.Companies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + ReturnedId + "%'").ToList(); } SearchWaterViewModels.BillingPeriods = BillingPeriods(); return(View(SearchWaterViewModels)); }
public PartialViewResult GetCompanies(string CompanyName) { if (!string.IsNullOrEmpty(CompanyName)) { ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup; List <Company> NewCompanies = new List <Company>(); List <Company> NewCompaniesPerGroup = new List <Company>(); NewCompanies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + CompanyName + "%'").ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); NewCompaniesPerGroup = searchCompanyPerGroup.Companies; SL.LogInfo(User.Identity.Name, Request.RawUrl, "Billing Generate- View/Get Companies - from Terminal: " + ipaddress); return(PartialView("_BillingSearchCompany", NewCompaniesPerGroup)); } else { List <Company> NewCompaniesPerGroup = new List <Company>(); return(PartialView("_BillingSearchCompany", NewCompaniesPerGroup)); } }
public void ProcessRequest(HttpContext context) { var a = context.Request.QueryString["Copy"].ToString(); var b = context.Request.QueryString["Type"].ToString(); var origin = context.Request.QueryString["Origin"].ToString(); var billing = context.Request.QueryString["Billing"].ToString(); DateTime originNew = Convert.ToDateTime(origin); DateTime billingNew = Convert.ToDateTime(billing); HttpFileCollection files = context.Request.Files; HttpPostedFile file = files["uploadData"]; int copy = int.Parse(a); BCS_Context db = new BCS_Context(); if ((file != null) && (file.ContentLength > 0) && (!string.IsNullOrEmpty(file.FileName))) { using (var dbtransaction = db.Database.BeginTransaction()) { try { ApplicationDbContext con = new ApplicationDbContext(); //db.PassedOnBillingInformation.RemoveRange(db.PassedOnBillingInformation) var userid = System.Web.HttpContext.Current.User.Identity.GetUserId(); var zonegroup = con.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(zonegroup); IEnumerable <Company> company = searchCompanyPerGroup.Companies; using (var package = new ExcelPackage(file.InputStream)) { var currentSheet = package.Workbook.Worksheets; var workSheet = currentSheet.First(); var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; for (int rowIterator = 12; rowIterator <= noOfRow; rowIterator++) { var compid = workSheet.Cells[rowIterator, 3].Value; var newCompId = int.Parse(compid.ToString()); Company comp = company.Where(m => m.CompanyID == newCompId).FirstOrDefault(); var type = workSheet.Cells[rowIterator, 12].Value.ToString() != null ? workSheet.Cells[rowIterator, 12].Value.ToString() : ""; if (type == b) { PassedOnBillingInformation passedOnBillingInformation = new PassedOnBillingInformation(); passedOnBillingInformation.Type = type; var cid = workSheet.Cells[rowIterator, 3].Value != null ? workSheet.Cells[rowIterator, 3].Value : 0; passedOnBillingInformation.CompanyId = int.Parse(cid.ToString()); passedOnBillingInformation.BillingPeriod = int.Parse(a); var amt = workSheet.Cells[rowIterator, 13].Value != null ? workSheet.Cells[rowIterator, 13].Value : 0; passedOnBillingInformation.Amount = decimal.Parse(amt.ToString()); passedOnBillingInformation.CreatedBy = userid; passedOnBillingInformation.CreateDate = DateTime.Now; passedOnBillingInformation.OriginDate = originNew; passedOnBillingInformation.BillingDate = billingNew; passedOnBillingInformation.Remarks = workSheet.Cells[rowIterator, 14].ToString(); db.PassedOnBillingInformation.Add(passedOnBillingInformation); db.SaveChanges(); } } } dbtransaction.Commit(); } catch (Exception ex) { var error = ex.Message; dbtransaction.Rollback(); } } } }
public bool EOMTransaction() { bool isSuccess = false; ApplicationDbContext context = new ApplicationDbContext(); string ZoneGroup = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup; SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(ZoneGroup); List <Company> Companies = searchCompanyPerGroup.Companies; using (var transaction = db.Database.BeginTransaction()) { try { int MaxId = db.EOMProcessing.Max(m => (int?)m.EOMNumber) ?? 0; BillingPeriod billingPeriod = new BillingPeriod(); billingPeriod = db.BillingPeriod.FirstOrDefault(m => m.BillingPeriodId == maxBillingPeriodId); billingPeriod.EOMStatus = "DONE"; db.Entry(billingPeriod).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); foreach (var item in Companies) { decimal[] Balance = new decimal[7]; int CompanyId = item.CompanyID; DateTime? CompanyDateCreated = db.Company.SingleOrDefault(m => m.CompanyID == CompanyId).CreateDate; for (int i = 0; i < BillingType.Count(); i++) { string billingtype = BillingType[i].ToString(); var Credit = db.SubsidiaryLedger.Where(m => m.BillingType.ToUpper() == billingtype).Where(m => m.CompanyId == CompanyId && m.BillingSubType.ToUpper() != "INTEREST").Sum(m => (decimal?)m.CreditAmount) ?? 0; var Debit = db.SubsidiaryLedger.Where(m => m.BillingType.ToUpper() == billingtype).Where(m => m.CompanyId == CompanyId && m.BillingSubType.ToUpper() != "INTEREST").Sum(m => (decimal?)m.DebitAmount) ?? 0; Balance[i] = Debit - Credit; } //Save to database if (!isExist(item.CompanyID)) { for (int i = 0; i < BillingType.Count() - 1; i++) { EOMProcessing eOMProcessing = new EOMProcessing(); eOMProcessing.CompanyId = CompanyId; eOMProcessing.BillingType = BillingType[i].ToString(); eOMProcessing.EOMNumber = ++MaxId; db.EOMProcessing.Add(eOMProcessing); db.SaveChanges(); } } for (int i = 0; i < BillingType.Count() - 1; i++) { string billingtype = BillingType[i].ToString(); EOMProcessing updateEOM = db.EOMProcessing.Where(m => m.CompanyId == CompanyId).Where(m => m.BillingType == billingtype).SingleOrDefault(); switch (month) { case 12: { updateEOM.November = Balance[i]; db.SaveChanges(); break; } case 11: { updateEOM.October = Balance[i]; db.SaveChanges(); break; } case 10: { updateEOM.September = Balance[i]; db.SaveChanges(); break; } case 9: { updateEOM.August = Balance[i]; db.SaveChanges(); break; } case 8: { updateEOM.July = Balance[i]; db.SaveChanges(); break; } case 7: { updateEOM.June = Balance[i]; db.SaveChanges(); break; } case 6: { updateEOM.May = Balance[i]; db.SaveChanges(); break; } case 5: { updateEOM.April = Balance[i]; db.SaveChanges(); break; } case 4: { updateEOM.March = Balance[i]; db.SaveChanges(); break; } case 2: { updateEOM.February = Balance[i]; db.SaveChanges(); break; } case 1: { updateEOM.January = 0; updateEOM.February = 0; updateEOM.March = 0; updateEOM.April = 0; updateEOM.May = 0; updateEOM.June = 0; updateEOM.July = 0; updateEOM.August = 0; updateEOM.September = 0; updateEOM.October = 0; updateEOM.November = 0; updateEOM.December = 0; int CompanyYear = CompanyDateCreated.Value.Year - DateTime.Now.Year; if (CompanyYear == 0) { updateEOM.PrevYr1 = Balance[i]; } else if (CompanyYear == 1) { updateEOM.PrevYr2 = Balance[i]; } else if (CompanyYear == 2) { updateEOM.PrevYr3 = Balance[i]; } else if (CompanyYear == 3) { updateEOM.PrevYr4 = Balance[i]; } else if (CompanyYear >= 4) { updateEOM.OtherPrevYr = Balance[i]; } //int prevYrToUpdate = 0; //if (updateEOM.PrevYr1 != null) // updateEOM.PrevYr1 = Balance[i]; //else if (updateEOM.PrevYr2 != null) // updateEOM.PrevYr2 = Balance[i]; //else if (updateEOM.PrevYr3 != null) // updateEOM.PrevYr3 = Balance[i]; //else if (updateEOM.PrevYr4 != null) // updateEOM.PrevYr4 = Balance[i]; //else if (updateEOM.OtherPrevYr != null) // updateEOM.OtherPrevYr = Balance[i]; ////below code will only use if multiple EOM Process in month of January. ////Check the latest prev year data. //if (updateEOM.PrevYr1 != null) // prevYrToUpdate++; //else if (updateEOM.PrevYr2 != null) // prevYrToUpdate++; //else if (updateEOM.PrevYr3 != null) // prevYrToUpdate++; //else if (updateEOM.PrevYr4 != null) // prevYrToUpdate++; //else if(updateEOM.OtherPrevYr != null) // prevYrToUpdate++; ////update the latest prev year data //if (prevYrToUpdate ==1) // updateEOM.PrevYr1 = Balance[i]; //else if (prevYrToUpdate == 2) // updateEOM.PrevYr2 = Balance[i]; //else if (prevYrToUpdate == 3) // updateEOM.PrevYr3 = Balance[i]; //else if (prevYrToUpdate == 4) // updateEOM.PrevYr4 = Balance[i]; //else if (prevYrToUpdate == 5) // updateEOM.OtherPrevYr = Balance[i]; db.SaveChanges(); break; } default: break; } } }//end foreach company transaction.Commit(); isSuccess = true; } catch (Exception ex) { transaction.Rollback(); } }//end transaction return(isSuccess); }
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)); } }
public ActionResult ViewRentals(string SearchInput, FormCollection frm, RentalInformation rentalinfo, string isEdit) { ApplicationDbContext context = new ApplicationDbContext(); 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.Rentals; //Result of initial search button if (!string.IsNullOrEmpty(SearchInput)) { SearchCompany searchcompany1 = new SearchCompany(); searchcompany1.SearchInput = SearchInput.ToString(); 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.CompanyList = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + SearchInput + "%' and ZoneGroup").ToList(); ViewBag.CompanySelected = ""; 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); SearchCompany searchcompany1 = new SearchCompany(); if (CanParse) { int ParsedCompanyID = int.Parse(frm[1].ToString()); searchcompany1.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == ParsedCompanyID).ToList(); searchcompany1.CompanyList = db.Company.Where(m => m.CompanyID == ParsedCompanyID).ToList(); searchcompany1.BillingRate = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList(); var bill = searchcompany1.BillingRate.GroupBy(m => m.SubCategory).ToList(); foreach (var item in bill) { searchcompany1.SubCategory.Add(item.Key.ToString()); } SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Search Company - from Terminal: " + ipaddress); ViewBag.CompanySelected = "OK"; } else { ViewBag.CompanySelected = ""; } return(View(searchcompany1)); } else if (isEdit == "True") //Edit transaction { var area = frm["Area"].Split(','); var newArea = ""; foreach (var item in area) { newArea = newArea + item; } RentalInformation rent = new RentalInformation(); int CompanyID = int.Parse(frm["CompanyID"].ToString()); //TryUpdateModel(rent); //if (ModelState.IsValid) //{ RentalInformation rentinfo = null; int ParsedIntRentID = int.Parse(frm["rentID"]); rentinfo = db.RentalInformation.Find(ParsedIntRentID); if (rentinfo != null) { rentinfo.Type = frm["Type"].ToString(); rentinfo.Rate = decimal.Parse(frm["Rate"]); rentinfo.Area = Math.Round(decimal.Parse(newArea), 2); rentinfo.Amount = Math.Round(decimal.Parse(frm["Rate"]) * decimal.Parse(frm["Area"]), 2); rentinfo.StartDate = DateTime.Parse(frm["StartDate"].ToString()); rentinfo.EndDate = DateTime.Parse(frm["EndDate"].ToString()); rentinfo.BillMode = frm["BillMode"].ToString(); rentinfo.DueOn = int.Parse(frm["DueOn"]); rentinfo.BillingMonths = frm["billingMonths"]; //rentinfo.BillingMonths = "1,2,3,4,5,6,7,8,9,10,11,12"; rentinfo.Currency = frm["Currency"].ToString(); rentinfo.UpdateDate = DateTime.Now; rentinfo.UpdatedBy = userid; db.Entry(rentinfo).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ViewBag.ValidatePostback = "True"; SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Edit - from Terminal: " + ipaddress); TempData["TransactionSuccess"] = "Edit"; //ViewBag.TransactionSuccess = "Edit"; } //} else { ViewBag.ValidatePostback = "False"; } SearchCompany searchcompany = new SearchCompany(); searchcompany.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == CompanyID).ToList(); searchcompany.CompanyList = db.Company.Where(m => m.CompanyID == CompanyID).ToList(); searchcompany.BillingRate = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList(); var bill = searchcompany.BillingRate.GroupBy(m => m.SubCategory).ToList(); foreach (var item in bill) { searchcompany.SubCategory.Add(item.Key); } ViewBag.CompanySelected = "OK"; TempData["SearchCompany"] = searchcompany; return(RedirectToAction("ViewRentalsRPG", "DataEntryRental")); //return View(searchcompany); } //If returned key/value pairs is > 3. "Add transaction is invoked else if (frm.Count > 3) { int OutIntParse; decimal OutDecimalParse; bool canParse = int.TryParse(frm["CompanyID"].ToString(), out OutIntParse); int parsedCompanyID = (canParse) ? int.Parse(frm["CompanyID"].ToString()) : 0; //int ParsedIntRentID = int.Parse(frm["RentalInformationId"]); RentalInformation rent = new RentalInformation(); TryUpdateModel(rent); //var errors = ModelState.Values.SelectMany(v => v.Errors); //UpdateModel<IRentalInformation>(rent); //if (ModelState.IsValid) //{ try { var r = frm["Rate"].ToString(); var s = r.Split(','); var newRate = ""; foreach (var item in s) { newRate += item; } decimal rate = Math.Round((decimal.TryParse(newRate, out OutDecimalParse)) ? decimal.Parse(newRate) : 0, 2); decimal area = Math.Round((decimal.TryParse(frm["Area"].ToString(), out OutDecimalParse)) ? decimal.Parse(frm["Area"].ToString()) : 0, 2); decimal amt = Math.Round(rate * area, 2); int RentalBillMode = (int.TryParse(frm["BillMode"].ToString(), out OutIntParse)) ? int.Parse(frm["BillMode"].ToString()) : 0; RentalInformation rentalinformation = new RentalInformation(); rentalinformation.CompanyId = parsedCompanyID; rentalinformation.Type = frm["Type"].ToString(); rentalinformation.Rate = rate; rentalinformation.Area = area; string str = frm["StartDate"].ToString(); rentalinformation.StartDate = Convert.ToDateTime(frm["StartDate"].ToString()); rentalinformation.EndDate = Convert.ToDateTime(frm["EndDate"].ToString()); //rentalinformation.BillMode = (int.TryParse(frm["BillMode"].ToString(), out OutIntParse)) ? int.Parse(frm["BillMode"].ToString()) : 0; rentalinformation.BillMode = frm["BillMode"].ToString(); rentalinformation.DueOn = (int.TryParse(frm["DueOn"].ToString(), out OutIntParse)) ? int.Parse(frm["DueOn"].ToString()) : 0; rentalinformation.BillingMonths = frm["billingMonths"]; //rentalinformation.BillingMonths = "1,2,3,4,5,6,7,8,9,10,11,12"; rentalinformation.CreatedDate = DateTime.Now; rentalinformation.Amount = amt; rentalinformation.Currency = frm["Currency"].ToString(); rentalinformation.CreatedBy = userid; db.RentalInformation.Add(rentalinformation); db.SaveChanges(); SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Add - from Terminal: " + ipaddress); TempData["TransactionSuccess"] = "Add"; //ViewBag.TransactionSuccess = "Add"; ViewBag.ValidatePostback = "True"; } catch (Exception) { ViewBag.ValidatePostback = "False"; } //} //else //{ // ViewBag.ValidatePostback = "False"; //} ViewBag.CompanySelected = "OK"; SearchCompany searchcompany = new SearchCompany(); searchcompany.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == parsedCompanyID).ToList(); searchcompany.CompanyList = db.Company.Where(m => m.CompanyID == parsedCompanyID).ToList(); searchcompany.BillingRate = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList(); var bill = searchcompany.BillingRate.GroupBy(m => m.SubCategory).ToList(); foreach (var item in bill) { searchcompany.SubCategory.Add(item.Key); } TempData["SearchCompany"] = searchcompany; return(RedirectToAction("ViewRentalsRPG", "DataEntryRental")); //return View(searchcompany); } //Default value else { SearchCompany searchcompany1 = new SearchCompany(); return(View(searchcompany1)); } }
public ActionResult ViewCompany(string SearchInput, string Rate, FormCollection frm) { SearchCompany searchcompany = new SearchCompany(); SearchCompany searchcompany1 = new SearchCompany(); ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; int SingleZoneGroupId = db.ZoneGroup.FirstOrDefault(d => d.ZoneGroupCode == ZoneGroup).ZoneGroupId; //Result of initial search button if (!string.IsNullOrEmpty(SearchInput)) { searchcompany1.SearchInput = SearchInput.ToString(); List <Company> NewCompanies = new List <Company>(); NewCompanies = db.Company.Where(x => x.CompanyName.Contains(SearchInput)).ToList().OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); searchcompany1.CompanyList = searchCompanyPerGroup.Companies; searchcompany1.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); ViewBag.SelectedCompany = "COMPSHOW"; 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); if (CanParse) { int ParsedCompanyID = int.Parse(frm[1].ToString()); List <Company> NewCompanies = new List <Company>(); NewCompanies = db.Company.Where(m => m.CompanyID == ParsedCompanyID).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); searchcompany1.CompanyList = searchCompanyPerGroup.Companies; } var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { searchcompany1.Category.Add(item.Category); } searchcompany1.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); ViewBag.SelectedCompany = "COMPHIDE"; return(View(searchcompany1)); } //If returned key/value pairs is > 3. "Add transaction is invoked else if (frm.Count > 3) { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User Added Item! (Maintenance Company) - from Terminal:" + ipaddress); Company companyinfo = new Company(); var CompCode = frm["CompanyCode"].ToString(); companyinfo.CompanyCode = frm["CompanyCode"].ToString(); companyinfo.CompanyName = frm["CompanyName"].ToString(); companyinfo.Phase = frm["Phase"].ToString(); companyinfo.Address = frm["Address"].ToString(); companyinfo.CreateDate = DateTime.Now.Date; companyinfo.Status = frm["Status"].ToString(); companyinfo.OwnershipType = frm["OwnershipType"].ToString(); companyinfo.EnterpriseType = frm["EnterpriseType"].ToString(); searchcompany1.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); searchcompany1.BillingRateList = db.BillingRates.Select(z => z).ToList(); var vat = frm["Vatable"].ToString(); if (vat == "YES") { companyinfo.VatableItems = "YES"; companyinfo.Vat = 12; } else { companyinfo.VatableItems = "NO"; } try { if (searchcompany1.ZoneList.Count != 0) { companyinfo.ZoneCode = frm["ZoneCode"].ToString(); } } catch { } try { if (searchcompany1.BillingRateList.Count != 0) { companyinfo.WithHolding = frm["WithHolding"].ToString(); } } catch { } companyinfo.SendEmail = frm["SendEmail"].ToString(); companyinfo.PrimaryEmailAddress = frm["AddEmailAddress"].ToString(); companyinfo.SecondaryEmailAddress = frm["AddSecondaryEmailAddress"].ToString(); try { companyinfo.DateOfRegistration = Convert.ToDateTime(frm["DateOfRegistration"].ToString()); } catch { } db.Company.Add(companyinfo); db.SaveChanges(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { searchcompany.Category.Add(item.Category); } List <Company> NewCompanies = new List <Company>(); NewCompanies = db.Company.Select(x => x).OrderByDescending(x => x.CompanyID).Take(50).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); searchcompany.CompanyList = searchCompanyPerGroup.Companies; searchcompany.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); TempData["TransactionSuccess"] = "Add"; TempData["searchcompany"] = searchcompany; TempData["SelectedCompany"] = "COMPHIDE"; return(RedirectToAction("ViewCompany", "MaintenanceCompany")); } else { Response.Write("<script> alert('Invalid Transaction!') </script>"); } //Default value //searchcompany.CompanyList = searchcompany.CompanyList.Select(x => x).ToList(); return(View("ViewCompany")); //return View(); }
public ActionResult UpdateCompany(FormCollection frmcollection) { ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; int SingleZoneGroupId = db.ZoneGroup.FirstOrDefault(d => d.ZoneGroupCode == ZoneGroup).ZoneGroupId; Company compinfo = null; int ParsedIntCompanyID = int.Parse(frmcollection["CompanyID"]); compinfo = db.Company.Find(ParsedIntCompanyID); SearchCompany searchcompany1 = new SearchCompany(); List <Company> NewCompanies = new List <Company>(); if (compinfo != null) { //compinfo.CompanyCode = frmcollection["CompanyCode"].ToString(); compinfo.CompanyName = frmcollection["CompanyName"].ToString(); compinfo.Phase = frmcollection["Phase"].ToString(); compinfo.Address = frmcollection["Address"].ToString(); searchcompany1.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); searchcompany1.BillingRateList = db.BillingRates.Select(z => z).ToList(); compinfo.UpdateDate = DateTime.Now.Date; compinfo.Status = frmcollection["Status"].ToString(); compinfo.OwnershipType = frmcollection["EditOwnershipType"].ToString(); compinfo.EnterpriseType = frmcollection["EnterpriseType"].ToString(); compinfo.SendEmail = frmcollection["SendEmail"].ToString(); compinfo.PrimaryEmailAddress = frmcollection["EmailAddress"].ToString(); compinfo.SecondaryEmailAddress = frmcollection["SecondaryEmailAddress"].ToString(); if (frmcollection["Vatable"].ToString() == "YES") { compinfo.Vat = 12; compinfo.VatableItems = frmcollection["Vatable"].ToString(); } else if (frmcollection["Vatable"].ToString() == "NO") { compinfo.VatableItems = "NO"; } else { compinfo.VatableItems = ""; } try { compinfo.DateOfRegistration = Convert.ToDateTime(frmcollection["EditDateOfRegistration"].ToString()); } catch { } if (searchcompany1.ZoneList.Count != 0) { compinfo.ZoneCode = frmcollection["ZoneCode"].ToString(); } try { if (searchcompany1.BillingRateList.Count != 0) { compinfo.WithHolding = frmcollection["WithHolding"].ToString(); } } catch (Exception) { //compinfo.VatableItems = null; compinfo.WithHolding = null; db.Entry(compinfo).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } finally { db.Entry(compinfo).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } else { Response.Write("<script> alert('Update Failed!') </script>"); TempData["IsSuccess"] = false; } int parsedCompanyID = int.Parse(frmcollection["CompanyID"]); SearchCompany searchcompany = new SearchCompany(); int CompId = Convert.ToInt32(frmcollection["CompanyID"]); //NewCompanies = db.Company.Select(x => x).OrderBy(x => x.CompanyName).Take(10).ToList(); NewCompanies = db.Company.Where(x => x.CompanyID == CompId).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); searchcompany.CompanyList = searchCompanyPerGroup.Companies; searchcompany.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); TempData["IsSuccess"] = true; TempData["TransactionSuccess"] = "Edit"; TempData["searchcompany"] = searchcompany; TempData["SelectedCompany"] = "COMPHIDE"; return(RedirectToAction("ViewCompany", "MaintenanceCompany")); }
// Search / Filter Company public ActionResult ViewSelectFilter(FormCollection frm) { ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; int SingleZoneGroupId = db.ZoneGroup.FirstOrDefault(d => d.ZoneGroupCode == ZoneGroup).ZoneGroupId; SearchCompany SearchCompanyViewModels = new SearchCompany(); List <Company> NewCompanies = new List <Company>(); if (frm.Count >= 1) { if (frm["SelectFilter"] == "All") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched all items! (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Select(x => x).OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Service Enterprise") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Service Enterprise (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Service Enterprise").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Logistics") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Logistics (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Logistics").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Utilities") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Utilities (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Utilities").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Regional Warehouse") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Warehouse (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Regional Warehouse").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Export Enterprise") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Export Enterprise (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Export Enterprise").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Domestic Market") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Domestic Market (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Domestic Market").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "IT Enterprise") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by IT Enterprise (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "IT Enterprise").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Facilities Enterprise") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Facilities Enterprise (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Facilities Enterprise").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Tourism Enterprise") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Tourism Enterprise (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Tourism Enterprise").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Agro-Industrial") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Agro-Industrial (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Agro-Industrial").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Developer Enterprise") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Developer Enterprise (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Developer Enterprise").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Free Trade") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Free Trade (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Free Trade").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Medical Tourism") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Medical Tourism (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Medical Tourism").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "PEZA Employees/Tenants") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by PEZA Employees/Tenants (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "PEZA Employees/Tenants").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else if (frm["SelectFilter"] == "Unknown") { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Unknown (Maintenance Company) - from Terminal:" + ipaddress); NewCompanies = db.Company.Where(x => x.EnterpriseType == "Unknown").OrderBy(x => x.CompanyName).ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies; SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList(); var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList(); foreach (var item in bill) { SearchCompanyViewModels.Category.Add(item.Category); } ViewBag.SelectedCompany = "COMPSHOW"; SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList(); } else { return(View()); } } return(View("ViewCompany", SearchCompanyViewModels)); }