Ejemplo n.º 1
0
        public ActionResult employeeLogout(User u)
        {
            if (set.id == u.Id && set.pass == u.Password)
            {
                List <Details> data = new List <Details>();
                //  Session["id"] = u.Id;
                Daily_times        d  = new Daily_times();
                List <Daily_times> dd = e.Daily_times.ToList();
                for (int i = dd.Count - 1; i >= 0; i--)
                {
                    if (dd[i].Id == u.Id)
                    {
                        d = dd[i];
                        break;
                    }
                }
                set.check = true;
                string o = System.DateTime.Now.DayOfWeek.ToString();
                //DateTime myDate = DateTime.Parse(DateTime.Now.TimeOfDay.ToString("hh\\:mm"));
                //d.start_time = DateTime.Parse(myDate.TimeOfDay.ToString());
                d.end_time = DateTime.Now;
                d.Id       = u.Id;
                //d.Day = o;
                //Session["LoginAttempt"] = 00;
                set.breakchecker        = 1;
                d.Status                = "Logged-OUT";
                Session["LoginAttempt"] = null;
                d.Day = o;

                SqlCommand sql = new SqlCommand("LOGOUTENDTIME", connection.getcon());
                sql.CommandType = System.Data.CommandType.StoredProcedure;
                sql.Parameters.AddWithValue("@id", d.DailyTime_id);
                sql.Parameters.AddWithValue("@endtime", d.end_time);
                sql.Parameters.AddWithValue("@status", d.Status);
                sql.ExecuteNonQuery();
                set.id   = 0;
                set.pass = null;
                return(RedirectToAction("details", "Home", new { u.Id }));
            }
            else
            {
                ViewBag.msg = "its not your id or password";
                return(View());
            }
        }
Ejemplo n.º 2
0
        public ActionResult breakStop(User u)
        {
            User t = e.Users.Find(u.Id);
            List <Daily_times> d  = e.Daily_times.ToList();
            Daily_times        dd = d.FindLast(x => x.User == t);

            e.Entry(dd).State = System.Data.Entity.EntityState.Modified;

            dd.check = 1;
            e.SaveChanges();
            if (u.Id == t.Id && t.Password == u.Password)
            {
                List <Break_Times> g = e.Break_Times.ToList();
                Break_Times        b = new Break_Times();

                for (int i = g.Count - 1; i >= 0; i--)
                {
                    if (g[i].Id == u.Id)
                    {
                        b = g[i];
                        break;
                    }
                }
                // string a = System.DateTime.Now.DayOfWeek.ToString();

                b.endTime = DateTime.Now;
                //set.breaktimestart = "00";
                b.Id = u.Id;
                SqlCommand sql = new SqlCommand("BREAKSTOP", connection.getcon());
                sql.CommandType = System.Data.CommandType.StoredProcedure;
                sql.Parameters.AddWithValue("@id", b.BreakTimeID);
                sql.Parameters.AddWithValue("@endtime", b.endTime);
                sql.ExecuteNonQuery();
                b.breakcheck = 00;
                return(RedirectToAction("details", "Home", new { u.Id }));
            }
            else
            {
                ViewBag.msg = "wrong id or pass";
            }
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult reports(User u)
        {
            Weekly_Reports        y = new Weekly_Reports();
            List <Weekly_Reports> q = e.Weekly_Reports.ToList();

            bool yes = false;

            foreach (var i in q)
            {
                if (i.Day_no == DateTime.Now.Day.ToString())
                {
                    yes = true;
                    break;
                }
            }

            if (yes)
            {
            }
            else
            {
                List <Daily_times> list = e.Daily_times.ToList();
                Daily_times        l    = list.Find(m => m.Id == u.Id);
                Weekly_Reports     p    = new Weekly_Reports();
                p.Day_no = (s.IndexOf(l.Day.Trim()) + 1).ToString();

                p.Start = DateTime.Parse(l.start_time.ToString());
                p.End   = DateTime.Parse(l.end_time.ToString());

                DateTime date1   = Convert.ToDateTime(l.start_time);
                DateTime date2   = Convert.ToDateTime(l.end_time);
                string   minutes = (date2.Subtract(date1).TotalMinutes).ToString();
                p.Total_Hours = minutes;
                e.Weekly_Reports.Add(p);
                e.SaveChanges();
            }
            return(RedirectToAction("showReports", "Home"));
        }
Ejemplo n.º 4
0
        public ActionResult employeeLogin(User u)
        {
            set.breaktimestart = "0";
            //SqlCommand sql = new SqlCommand("INSERTTIME", connection.getcon());
            //sql.CommandType = System.Data.CommandType.StoredProcedure;
            //sql.Parameters.AddWithValue("@fk_id", u.Id);
            //sql.Parameters.AddWithValue("@status", "Logged_IN");
            //sql.Parameters.AddWithValue("@startTime", d.start_time );
            //sql.Parameters.AddWithValue("@day",o );
            //sql.ExecuteNonQuery();

            List <User> list = e.Users.ToList();
            User        r    = list.Find(p => p.Id == u.Id);



            User x = e.Users.Find(r.Id);

            //DateTime start = new DateTime(2018, 12, 9, 10, 0, 0); //10 o'clock
            //DateTime end = new DateTime(2009, 12, 10, 12, 0, 0); //12 o'clock
            //DateTime now = DateTime.Now;

            List <Daily_times> list1 = e.Daily_times.ToList();
            Daily_times        l     = list1.Find(m => m.Id == u.Id);

            if (l == null)
            {
                l     = new Daily_times();
                l.Day = DateTime.Now.Day.ToString();
            }
            //Daily_time q = e.Daily_times.Find(l.Id);
            string o = System.DateTime.Now.DayOfWeek.ToString();

            if (l.Day.Trim() == o)
            {
                e.Entry(l).State = System.Data.Entity.EntityState.Modified;
                l.start_time     = DateTime.Now;

                //e.Daily_times.
                //e.Daily_times.Add(l);
                e.SaveChanges();
            }


            if (x.Password == u.Password)
            {
                set.id = u.Id;
                //Session["id"] = x.Id;
                if (l.Status == "Logged-IN")
                {
                    ViewBag.msg = "User is Already Logged in";
                    // Session["id"] = x.Id;
                    x.check  = x.Id;
                    set.id   = x.Id;
                    set.pass = x.Password;
                    Session["LoginAttempt"] = null;


                    RedirectToAction("employeeLogin", "Home");
                }


                //if (z == "Logged-IN")
                //{
                //    ViewBag.msg = "User is Already Logged in";
                //    RedirectToAction("employeeLogin", "Home");
                //}
                else
                {
                    if (l.User == null)
                    {
                        Session["id"] = x.Id;
                        set.id        = x.Id;
                        set.pass      = x.Password;
                        Daily_times d      = new Daily_times();
                        string      a      = System.DateTime.Now.DayOfWeek.ToString();
                        DateTime    myDate = DateTime.Parse(DateTime.Now.TimeOfDay.ToString("hh\\:mm"));
                        d.start_time = DateTime.Parse(myDate.TimeOfDay.ToString());
                        d.Month      = DateTime.Now.ToString("MMM");
                        //d.end_time = DateTime.Now;
                        d.Day = a;
                        d.Id  = u.Id;

                        d.Status = "Logged-IN";
                        Session["LoginAttempt"] = null;
                        Break_Times b = new Break_Times();
                        b.breakcheck = 0;
                        e.Daily_times.Add(d);
                        e.SaveChanges();
                    }
                }
                return(RedirectToAction("details", "Home", new { x.Id }));
            }
            else
            {
                ViewBag.msg = "Wrong password";
            }

            return(View());
        }