Esempio n. 1
0
        public ActionResult GetDahboard(int?Locationid, DateTime?Date)
        {
            TAS2013Entities db           = new TAS2013Entities();
            User            LoggedInUser = Session["LoggedUser"] as User;
            DashboardValues dv           = new DashboardValues();
            List <Emp>      emplist      = new List <Emp>();

            if (Date == null)
            {
                Date = DateTime.Today;
            }
            //if (DateEnd == null)
            //    DateEnd = DateTime.Today;
            List <ViewAttData>   ViewAttDataList   = new List <ViewAttData>();
            List <ViewAttData>   ViewAttDataListGH = new List <ViewAttData>();
            List <JobCardDetail> jcEmp             = new List <JobCardDetail>();

            jcEmp = db.JobCardDetails.Where(aa => aa.Dated == Date).ToList();
            DateTime dts = new DateTime(Date.Value.Year, Date.Value.Month, 1);
            DateTime dte = new DateTime(Date.Value.Year, Date.Value.Month, DateTime.DaysInMonth(Date.Value.Year, Date.Value.Month));

            if (Locationid == 0)
            {
                emplist           = db.Emps.Where(aa => aa.Status == true).ToList();
                ViewAttDataListGH = db.ViewAttDatas.Where(aa => aa.AttDate >= dts && aa.AttDate <= dte).ToList();
                ViewAttDataList   = ViewAttDataListGH.Where(aa => aa.AttDate == Date && aa.DesigID != 24).ToList();
            }
            else
            {
                emplist           = db.Emps.Where(aa => aa.LocID == Locationid && aa.Status == true).ToList();
                ViewAttDataListGH = db.ViewAttDatas.Where(aa => aa.LocID == Locationid && aa.AttDate >= dts && aa.AttDate <= dte).ToList();
                ViewAttDataList   = ViewAttDataListGH.Where(aa => aa.LocID == Locationid && aa.AttDate == Date && aa.DesigID != 24).ToList();
                jcEmp             = db.JobCardDetails.Where(aa => aa.Dated == Date).ToList();
            }
            dv.DateStart    = (DateTime)Date;
            dv.LocationName = db.Locations.First(aa => aa.LocID == Locationid).LocName;
            //dv.DateEnd = (DateTime)DateEnd;
            dv.TotalEmps         = ViewAttDataList.Where(aa => aa.DesigID != 24).Select(aa => aa.EmpID).Distinct().Count();
            dv.Present           = ViewAttDataList.Where(aa => aa.StatusP == true).Count();
            dv.Absent            = ViewAttDataList.Where(aa => aa.StatusAB == true).Count();
            dv.Leaves            = ViewAttDataList.Where(aa => aa.StatusLeave == true).Count();
            dv.TotalEmpAllLoc    = db.Emps.Where(aa => aa.Status == true).Count();
            dv.TotalPresent      = db.AttDatas.Where(aa => aa.StatusP == true && aa.AttDate == Date).Count();
            dv.TotalAbsent       = db.ViewAttDatas.Where(aa => aa.StatusAB == true && aa.AttDate == Date).Count();
            dv.TotalLeaves       = db.AttDatas.Where(aa => aa.StatusLeave == true && aa.AttDate == Date).Count();
            dv.TotalVisitors     = db.ViewAttDatas.Where(aa => aa.AttDate == Date && aa.TimeIn != null).Count();
            dv.JCTraining        = jcEmp.Where(aa => aa.WrkCardID == 7).ToList().Count;
            dv.JCFieldTour       = jcEmp.Where(aa => aa.WrkCardID == 5).ToList().Count;
            dv.JCOfficialDuty    = jcEmp.Where(aa => aa.WrkCardID == 1).ToList().Count;
            dv.DashboardGraphObj = GetDahboardGraph(dts, dte, ViewAttDataListGH);
            if (HttpContext.Request.IsAjaxRequest())
            {
                return(View("DashboardContainer", dv));
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult GetDahboard()
        {
            //DateTime dt = DateTime.Today.AddDays(-1);
            DateTime dt = new DateTime(2016, 02, 02);
            DashboardValues dv = new DashboardValues();
            TAS2013Entities db = new TAS2013Entities();
            List<DailySummary> ds = new List<DailySummary>();
            List<JobCardEmp> jcEmp = new List<JobCardEmp>();
            if (dt.DayOfWeek == DayOfWeek.Saturday)
                dt = dt.AddDays(-1);
            if (dt.DayOfWeek == DayOfWeek.Sunday)
                dt = dt.AddDays(-2);
            jcEmp = db.JobCardEmps.Where(aa => aa.Dated == dt).ToList();
            List<JobCardTime> jcEmpT = new List<JobCardTime>();
            jcEmpT = db.JobCardTimes.Where(aa => aa.DutyDate == dt).ToList();
            ds = db.DailySummaries.Where(aa => aa.Date == dt && aa.Criteria == "C").ToList();
            if (ds.Count > 0)
            {
                dv.DateTime = dt.ToString("dd-MMM-yyy");
                dv.TotalEmps = (short)ds.FirstOrDefault().TotalEmps;
                dv.Present = (short)ds.FirstOrDefault().PresentEmps;
                dv.Absent = (short)ds.FirstOrDefault().AbsentEmps;
                dv.Leaves = (short)ds.FirstOrDefault().LvEmps;
                dv.LateIn = (short)ds.FirstOrDefault().LIEmps;
                dv.LateOut = (short)ds.FirstOrDefault().LOEmps;
                dv.EarlyIn = (short)ds.FirstOrDefault().EIEmps;
                dv.EarlyOut = (short)ds.FirstOrDefault().EOEmps;
                dv.OverTime = (short)ds.FirstOrDefault().OTEmps;
                dv.ShortLeaves = (short)ds.FirstOrDefault().ShortLvEmps;
                dv.JCOfficalAssignment = jcEmp.Where(aa => aa.WrkCardID == 11).ToList().Count + jcEmpT.Where(aa=>aa.JobCardID==11).Count();
                dv.JCTour = jcEmp.Where(aa => aa.WrkCardID == 9).ToList().Count + jcEmpT.Where(aa => aa.JobCardID == 9).Count();
                dv.JCTraining = jcEmp.Where(aa => aa.WrkCardID == 8).ToList().Count + jcEmpT.Where(aa => aa.JobCardID == 8).Count();
                dv.JCVisit = jcEmp.Where(aa => aa.WrkCardID == 10).ToList().Count + jcEmpT.Where(aa => aa.JobCardID == 10).Count();
                dv.EWork = (int)(ds.FirstOrDefault().ExpectedWorkMins / 60);
                dv.AWork = (int)(ds.FirstOrDefault().ActualWorkMins / 60);
                dv.LWork = (int)(ds.FirstOrDefault().LossWorkMins / 60);
            }
            else
            {
                dv.DateTime = dt.ToString("dd-MMM-yyy");
                dv.TotalEmps = 0;
                dv.Present = 0;
                dv.Absent = 0;
                dv.Leaves = 0;
                dv.LateIn = 0;
                dv.LateOut = 0;
                dv.EarlyIn = 0;
                dv.EarlyOut = 0;
                dv.OverTime = 0;
                dv.ShortLeaves = 0;
                dv.JCOfficalAssignment = jcEmp.Where(aa => aa.WrkCardID == 11).ToList().Count;
                dv.JCTour = jcEmp.Where(aa => aa.WrkCardID == 9).ToList().Count;
                dv.JCTraining = jcEmp.Where(aa => aa.WrkCardID == 8).ToList().Count;
                dv.JCVisit = jcEmp.Where(aa => aa.WrkCardID == 10).ToList().Count;
            }
            if (HttpContext.Request.IsAjaxRequest())
                return Json(dv
                           , JsonRequestBehavior.AllowGet);

            return RedirectToAction("Index");
        }
Esempio n. 3
0
        public ActionResult GetDahboard()
        {
            DateTime dt = DateTime.Today.AddDays(-1);
            //DateTime dt = new DateTime(2016, 02, 02);
            DashboardValues      dv    = new DashboardValues();
            TAS2013Entities      db    = new TAS2013Entities();
            List <DailySummary>  ds    = new List <DailySummary>();
            List <JobCardDetail> jcEmp = new List <JobCardDetail>();

            if (dt.DayOfWeek == DayOfWeek.Saturday)
            {
                dt = dt.AddDays(-1);
            }
            if (dt.DayOfWeek == DayOfWeek.Sunday)
            {
                dt = dt.AddDays(-2);
            }
            jcEmp = db.JobCardDetails.Where(aa => aa.Dated == dt).ToList();
            ds    = db.DailySummaries.Where(aa => aa.Date == dt && aa.Criteria == "C").ToList();
            if (ds.Count > 0)
            {
                dv.DateTime    = dt.ToString("dd-MMM-yyy");
                dv.TotalEmps   = (short)ds.FirstOrDefault().TotalEmps;
                dv.Present     = (short)ds.FirstOrDefault().PresentEmps;
                dv.Absent      = (short)ds.FirstOrDefault().AbsentEmps;
                dv.Leaves      = (short)ds.FirstOrDefault().LvEmps;
                dv.LateIn      = (short)ds.FirstOrDefault().LIEmps;
                dv.LateOut     = (short)ds.FirstOrDefault().LOEmps;
                dv.EarlyIn     = (short)ds.FirstOrDefault().EIEmps;
                dv.EarlyOut    = (short)ds.FirstOrDefault().EOEmps;
                dv.OverTime    = (short)ds.FirstOrDefault().OTEmps;
                dv.ShortLeaves = (short)ds.FirstOrDefault().ShortLvEmps;
                dv.JCFieldTour = jcEmp.Where(aa => aa.WrkCardID == 5).ToList().Count;
                dv.JCTraining  = jcEmp.Where(aa => aa.WrkCardID == 7).ToList().Count;
                dv.JCSeminar   = jcEmp.Where(aa => aa.WrkCardID == 8).ToList().Count;
                dv.JCOD        = jcEmp.Where(aa => aa.WrkCardID == 1).ToList().Count;
                //dv.JCFieldTour = 80;
                //dv.JCTraining = 90;
                //dv.JCSeminar = 80;
                //dv.JCOD = 80;
                dv.EWork = (int)(ds.FirstOrDefault().ExpectedWorkMins / 60);
                dv.AWork = (int)(ds.FirstOrDefault().ActualWorkMins / 60);
                dv.LWork = (int)(ds.FirstOrDefault().LossWorkMins / 60);
            }
            else
            {
                var countOfRows = db.DailySummaries.Count();
                if (countOfRows > 1)
                {
                    ds = db.DailySummaries.ToList();
                    DailySummary dss = ds[countOfRows - 1];
                    dv.DateTime    = ds[countOfRows - 1].Date.Value.Date.ToString("dd-MMM-yyy");
                    dv.TotalEmps   = (short)ds[countOfRows - 1].TotalEmps;
                    dv.Present     = (short)ds[countOfRows - 1].PresentEmps;
                    dv.Absent      = (short)ds[countOfRows - 1].AbsentEmps;
                    dv.Leaves      = (short)ds[countOfRows - 1].LvEmps;
                    dv.LateIn      = (short)ds[countOfRows - 1].LIEmps;
                    dv.LateOut     = (short)ds[countOfRows - 1].LOEmps;
                    dv.EarlyIn     = (short)ds[countOfRows - 1].EIEmps;
                    dv.EarlyOut    = (short)ds[countOfRows - 1].EOEmps;
                    dv.OverTime    = (short)ds[countOfRows - 1].OTEmps;
                    dv.ShortLeaves = (short)ds[countOfRows - 1].ShortLvEmps;
                    dv.JCFieldTour = jcEmp.Where(aa => aa.WrkCardID == 5).ToList().Count;
                    dv.JCTraining  = jcEmp.Where(aa => aa.WrkCardID == 7).ToList().Count;
                    dv.JCSeminar   = jcEmp.Where(aa => aa.WrkCardID == 8).ToList().Count;
                    dv.JCOD        = jcEmp.Where(aa => aa.WrkCardID == 1).ToList().Count;
                    //dv.JCFieldTour = 80;
                    //dv.JCTraining = 90;
                    //dv.JCSeminar = 80;
                    //dv.JCOD = 80;
                    dv.EWork = (int)(ds.FirstOrDefault().ExpectedWorkMins / 60);
                    dv.AWork = (int)(ds.FirstOrDefault().ActualWorkMins / 60);
                    dv.LWork = (int)(ds.FirstOrDefault().LossWorkMins / 60);
                }
            }
            if (HttpContext.Request.IsAjaxRequest())
            {
                return(Json(dv
                            , JsonRequestBehavior.AllowGet));
            }

            return(RedirectToAction("Index"));
        }