public ActionResult Advanced(int employee_id, string DateFrom, string DateTo) { AdvancedVM vm = new AdvancedVM { employee_id = employee_id, DateFrom = DateTime.Parse(DateFrom), DateTo = DateTime.Parse(DateTo) }; using (HardwareDBEntities db = new HardwareDBEntities()) { db.Configuration.ProxyCreationEnabled = false; vm.Employee = GetEmployee(vm.employee_id); vm.employee = db.lgemployees.Where(x => x.emp_num == vm.employee_id).FirstOrDefault(); var test = db.lginvoices.Where(i => i.employee_id == vm.employee.emp_num).Where(i => i.inv_DATETIME <vm.DateTo && i.inv_DATETIME> vm.DateFrom).ToList().Select(r => new SalesRecord { OrderDate = (DateTime)r.inv_DATETIME, Amount = Convert.ToDouble(r.inv_total), Employee = vm.employee.emp_fname }).ToList(); vm.results = test; vm.chartData = test.GroupBy(g => g.Employee).ToDictionary(g => g.Key, g => g.Sum(v => v.Amount)); TempData["chartData"] = vm.chartData; TempData["records"] = test.ToList(); TempData["employee"] = vm.employee; return(View("ADVReporting", vm)); } }
public ActionResult Advanced() { AdvancedVM vm = new AdvancedVM(); vm.Departments = GetDepartments(0); vm.DateFrom = new DateTime(1976, 01, 01); //1976-01-01 vm.DateTo = new DateTime(2011, 12, 31); vm.counter = 0; return(View(vm)); }
public ActionResult ADVReporting() { AdvancedVM vm = new AdvancedVM(); //Retrieve a list of Employee ids so that it can be used to populate the dropdown on the View vm.Employee = GetEmployee(0); //Set default values for the FROM and TO dates vm.DateFrom = new DateTime(2014, 12, 1); vm.DateTo = new DateTime(2014, 12, 31); return(View(vm)); }
public ActionResult Advanced() { AdvancedVM vm = new AdvancedVM(); //to retrieve a list of all the employess to populate the dropdown vm.lgemployees = GetEmployees(0); //Set default values for the FROM and TO dates vm.DateFrom = new DateTime(2011, 01, 1); vm.DateTo = new DateTime(2011, 12, 31); return(View(vm)); }
public ActionResult Advanced(AdvancedVM vm) { using (HardwareDBEntities db = new HardwareDBEntities()) { db.Configuration.ProxyCreationEnabled = false; //to retrieve a list of the employees so as to populate the dropdown vm.lgemployees = GetEmployees(vm.Selectedemp_num); //to get the full details of the selected employee so that it can displayed on the view vm.employee = db.lgemployees.Where(x => x.emp_num == vm.Selectedemp_num).FirstOrDefault(); //to get all the invoice details that adheres to the entered criteria //For each of the results, load data into a new ReportRecord object var temp = db.lginvoices.Include("lgcustomer").ToList(); var date = temp.Where(pp => pp.employee_id == vm.employee.emp_num && pp.inv_DATETIME >= vm.DateFrom && pp.inv_DATETIME <= vm.DateTo).ToList(); var list = date.ToList().Select(rr => new ReportRecord { INV_Date = rr.inv_DATETIME.ToString(), Amount = Convert.ToDouble(rr.inv_total), //Customer = db.lgcustomers.Where(pp => pp.cust_code == rr.cust_code).Select(x => x.cust_fname + " " + x.cust_lname).FirstOrDefault(), Customer = rr.lgcustomer.cust_fname, Employee_id = Convert.ToInt32(rr.employee_id) }); vm.results = list.GroupBy(g => g.Customer).ToList(); //Load the list of ReportRecords returned by the above query into a new dictionary grouped by Employee //This will be used to generate the chart on the View through the MicroSoft Charts helper vm.chartData = list.GroupBy(g => g.Customer).ToDictionary(g => g.Key, g => g.Sum(v => v.Amount)); //Store the chartData dictionary in temporary data so that it can be accessed by the EmployeeOrdersChart action resonsible for generating the chart TempData["chartData"] = vm.chartData; TempData["records"] = list.ToList(); TempData["employee"] = vm.employee; return(View(vm)); } }
public ActionResult Advanced(AdvancedVM vm) { using (HardwareDBEntities db = new HardwareDBEntities()) { db.Configuration.ProxyCreationEnabled = false; List <DepartmentEmployees> empList = new List <DepartmentEmployees>(); foreach (var employee in db.lgemployees.Where(emp => vm.SelectedDepartmentID == emp.dept_num && vm.DateFrom <= emp.emp_hireDATETIME && vm.DateTo >= emp.emp_hireDATETIME)) { empList.Add(new DepartmentEmployees { EmployeeFName = employee.emp_fname, EmployeeSName = employee.emp_lname, EmployeeEmail = employee.emp_email, EmployeeTitle = employee.emp_title, EmplyeeID = employee.emp_num, deptNum = employee.dept_num.Value }); } vm.Departments = GetDepartments(vm.SelectedDepartmentID); vm.department = db.lgdepartments.Where(x => x.dept_num == vm.SelectedDepartmentID).FirstOrDefault(); //vm.department = db.dep.Where(x => x.BusinessEntityID == vm.SelectedVendorID).FirstOrDefault(); vm.depEmployess = empList; vm.results = empList.GroupBy(g => g.EmployeeTitle).ToList(); empList.ToList(); vm.chartData = empList.GroupBy(g => g.EmployeeTitle).ToDictionary(g => g.Key, g => (double)g.Sum(v => v.deptNum)); vm.counter = empList.Count(); TempData["chartData"] = vm.chartData; TempData["records"] = empList.ToList(); TempData["department"] = vm.department; return(View(vm)); } }