public ActionResult Dashboard() { try { Session["HasHomeBased"] = false; StaffDetails details = StaffDetails.GetInstance(); bool hasHomeBased = false; if (Session["Roleid"].ToString().Contains("b4d86d72-0b86-41b2-adc4-5ccce7e9775b")) { details.AgencyId = new Guid(Session["AgencyID"].ToString()); details.RoleId = new Guid(Session["RoleID"].ToString()); details.UserId = new Guid(Session["UserID"].ToString()); hasHomeBased = new TeacherData().CheckUserHasHomeBased(details); Session["HasHomeBased"] = hasHomeBased; ViewBag.RoleName = "Center Manager"; ViewBag.ViewType = "Center"; } else if (Session["Roleid"].ToString().Contains("7c2422ba-7bd4-4278-99af-b694dcab7367")) { ViewBag.RoleName = "Executive"; ViewBag.ViewType = "Agency"; } else if (Session["Roleid"].ToString().Contains("2af7205e-87b4-4ca7-8ca8-95827c08564c")) { ViewBag.RoleName = "Area Manager"; ViewBag.ViewType = "Center"; } ExecutiveDashBoard executive = new ExecutiveDashBoard(); executive = new ExecutiveData().GetExecutiveDetails(Session["AgencyID"].ToString(), Session["UserID"].ToString(), Session["Roleid"].ToString()); TempData["CaseNote"] = executive.listCaseNote; return(View(executive)); } catch (Exception Ex) { clsError.WriteException(Ex); return(View()); } }
public ExecutiveDashBoard GetExecutiveDetails(string Agencyid, string userid, string Command) { ExecutiveDashBoard executive = new ExecutiveDashBoard(); try { command.Parameters.Add(new SqlParameter("@Agencyid", Agencyid)); command.Parameters.Add(new SqlParameter("@userid", userid)); command.Parameters.Add(new SqlParameter("@Command", Command)); command.Connection = Connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "SP_GetEACDashboardDetails"; command.CommandTimeout = 120; DataAdapter = new SqlDataAdapter(command); _dataset = new DataSet(); DataAdapter.Fill(_dataset); if (_dataset != null && _dataset.Tables.Count > 0) { //SeatsandSlots if (_dataset.Tables[0].Rows.Count > 0) { executive.AvailablePercentage = _dataset.Tables[0].Rows[0]["AvailablePercentage"].ToString(); executive.AvailableSeat = _dataset.Tables[0].Rows[0]["AvailableSeat"].ToString(); executive.YesterDayAttendance = _dataset.Tables[0].Rows[0]["YesterDayAttendance"].ToString(); executive.ADA = _dataset.Tables[0].Rows[0]["ADA"].ToString(); executive.WaitingList = Math.Round(Convert.ToDouble(_dataset.Tables[0].Rows[0]["WaitingListPercentage"].ToString()), 1).ToString("N1"); executive.WaitingListCount = Math.Round(Convert.ToDouble(_dataset.Tables[0].Rows[0]["WaitingListCount"].ToString()), 1).ToString(); } //EmployeeBirhday if (_dataset != null && _dataset.Tables[1].Rows.Count > 0) { foreach (DataRow dr in _dataset.Tables[1].Rows) { if (dr["Staff"] != null && dr["Staff"].ToString() != "") { executive.EmployeeBirthdayList.Add(new ExecutiveDashBoard.EmployeeBirthday { Staff = dr["Staff"].ToString(), DateOfBirth = Convert.ToDateTime(dr["DOB"].ToString()).ToString("MMM-dd") }); } } } //EnrolledByProgram if (_dataset.Tables[2].Rows.Count > 0) { foreach (DataRow dr in _dataset.Tables[2].Rows) { executive.EnrolledProgramList.Add(new ExecutiveDashBoard.EnrolledProgram { ProgramType = dr["ProgramType"].ToString(), Total = dr["Total"].ToString(), Available = dr["Available"].ToString() }); } } //ClassRoomType if (_dataset.Tables[3].Rows.Count > 0) { foreach (DataRow dr in _dataset.Tables[3].Rows) { executive.ClassRoomTypeList.Add(new ExecutiveDashBoard.ClassRoomType { ClassSession = GetClassSession(dr["ClassSession"].ToString()), Total = dr["Total"].ToString(), Available = dr["Available"].ToString() }); } } //MissingScreen if (_dataset != null && _dataset.Tables[4].Rows.Count > 0) { foreach (DataRow dr in _dataset.Tables[4].Rows) { executive.MissingScreenList.Add(new ExecutiveDashBoard.MissingScreen { Name = dr["Name"].ToString(), Screen = dr["MissingScreen"].ToString() }); } } //FamilyOverIncome if (_dataset.Tables[5].Rows.Count > 0) { decimal IncomePercentage = !string.IsNullOrEmpty(_dataset.Tables[5].Rows[0][0].ToString()) ? Convert.ToDecimal(_dataset.Tables[5].Rows[0][0].ToString()) : 0; //decimal Count = _dataset.Tables[5].Rows.Count; //decimal OverIncomeCount = 0; //foreach (DataRow dr in _dataset.Tables[5].Rows) //{ // decimal IncomePercentage = Convert.ToInt32(dr["IncomePercentage"].ToString()); // if (IncomePercentage > 100) // OverIncomeCount++; //} //decimal Remaining = OverIncomeCount; //Count = (Remaining * 100) / Count; executive.FamilyOverIncome = Math.Round(IncomePercentage, 1).ToString(); } if (string.IsNullOrEmpty(executive.FamilyOverIncome)) { executive.FamilyOverIncome = "0"; } //Disability if (_dataset.Tables[6].Rows.Count > 0) { //decimal Count = _dataset.Tables[6].Rows.Count; //decimal Disabilities = 0; //foreach (DataRow dr in _dataset.Tables[6].Rows) //{ // int NoOfDisable = Convert.ToInt32(dr["ParentDisable"].ToString()); // if (NoOfDisable == 1) // Disabilities++; //} //decimal Remaining = Disabilities; //Count = (Remaining * 100) / Count; //executive.DisabilityPercentage = Math.Round(Count, 1).ToString(); executive.DisabilityPercentage = _dataset.Tables[6].Rows[0]["DisabilityPercentage"].ToString(); } if (string.IsNullOrEmpty(executive.DisabilityPercentage)) { executive.DisabilityPercentage = "0"; } //ThermHoursAndDollars if (_dataset.Tables[7].Rows.Count > 0) { decimal Count = _dataset.Tables[7].Rows.Count; executive.ThermHours = _dataset.Tables[7].Rows[0]["TotalHours"].ToString(); executive.ThermDollars = _dataset.Tables[7].Rows[0]["Dollars"].ToString(); } //CaseNote if (_dataset.Tables[8].Rows.Count > 0) { foreach (DataRow dr in _dataset.Tables[8].Rows) { executive.listCaseNote.Add(new ExecutiveDashBoard.CaseNote { Month = dr["Month"].ToString(), Percentage = dr["Percentage"].ToString() }); } } //Total Hours and Dollers if (_dataset.Tables[9].Rows.Count > 0) { foreach (DataRow dr in _dataset.Tables[9].Rows) { executive.TotalHours = dr["Hours"].ToString(); executive.TotalDollars = dr["Budget"].ToString(); } } } } catch (Exception ex) { clsError.WriteException(ex); } finally { if (Connection != null) { Connection.Close(); } } return(executive); }