Exemplo n.º 1
0
        public PartialViewResult GetUserHistory(FormCollection collection)
        {
            var    userList = MembershipUserExtended.GetFullNameUserNameList();
            string userName = collection["SelectedValue"];

            if (userList.ContainsValue(userName))
            {
                DateTime startDate;
                DateTime endDate;
                if (DateTime.TryParse(collection["txtStartDate"], out startDate) && DateTime.TryParse(collection["txtEndDate"], out endDate))
                {
                    var model = TimeTrackManager.GetUserTimeTrackHistoryForSpecifiedPeriod(userName, startDate, endDate);
                    return(PartialView("_GetUserHistory", model));
                }
            }

            return(PartialView("_GetUserHistory", new CustomTimeTrack()));
        }
Exemplo n.º 2
0
        public void ExportUserHistory(FormCollection collection)
        {
            var    userList = MembershipUserExtended.GetFullNameUserNameList();
            string userName = collection["uname"];

            if (userList.ContainsValue(userName))
            {
                DateTime startDate;
                DateTime endDate;
                if (DateTime.TryParse(collection["startDate"], out startDate) && DateTime.TryParse(collection["endDate"], out endDate))
                {
                    var model = TimeTrackManager.GetUserTimeTrackHistoryForSpecifiedPeriod(userName, startDate, endDate);
                    //return PartialView("_GetUserHistory", model);
                    IExportPage export     = new ExportPage();
                    var         reportName = model.EmployeeName.Replace(" ", "_") + "_" + model.CustomStartEndDateDisplay.Replace(" ", "-");
                    export.ExportExcel(ExcelReportHelper.GetExcelString(model, reportName), reportName + ".xls");
                }
            }

            //return PartialView("_GetUserHistory", new CustomTimeTrack());
        }
Exemplo n.º 3
0
        public PartialViewResult GetTimeTrackForEdit(FormCollection collection)
        {
            var    userList = MembershipUserExtended.GetFullNameUserNameList();
            string userName = collection["SelectedValue"];

            if (userList.ContainsValue(userName))
            {
                DateTime startDate;
                if (DateTime.TryParse(collection["txtStartDate"], out startDate))
                {
                    var endDate = startDate;
                    var model   = TimeTrackManager.GetDailyClockInOutTimeByDate(userName, startDate, endDate);

                    ViewBag.UserName = userName;
                    //ViewBag.UserFullName = collection["user"];
                    return(PartialView("_TimeTrackForEdit", new DailyTimeTrackViewModel(model, userList.FindKeyByValue(userName), userName)));
                }
            }

            return(PartialView("_TimeTrackForEdit", new DailyTimeTrackViewModel()));
        }
Exemplo n.º 4
0
        public ActionResult Create(UserTimeTrackHistoryMapped utth, FormCollection collection)
        {
            var    userList = MembershipUserExtended.GetFullNameUserNameList();
            string userName = collection["UserName"];

            if (userList.ContainsValue(userName))
            {
                utth.UserName = userName;

                DateTime clockInDt;
                DateTime clockOutDt;
                if (DateTime.TryParse(utth.ClockInTime, out clockInDt) && DateTime.TryParse(utth.ClockOutTime, out clockOutDt))
                {
                    if (clockOutDt.TimeOfDay.CompareTo(clockInDt.TimeOfDay) != -1) // if clock out time is earlier than clock in time than error
                    {
                        utth.ClockInTime  = string.Format("{0:t}", clockInDt);
                        utth.ClockOutTime = string.Format("{0:t}", clockOutDt);

                        utth.UserId      = MembershipUserExtended.GetUserIdByUserName(userName);
                        utth.CreatedBy   = LoggedInUserName;
                        utth.CreatedDate = WebHelpers.GetCurrentDateTimeByTimeZoneId(WebConfigurationManager.AppSettings["UserTimeZoneId"]);
                        utth.IsDeleted   = false;
                        var tth = utth.Get(utth.Save());
                        tth.UserName    = userList.FindKeyByValue(userName);
                        ViewBag.Message = "Record inserted successfully.";
                        return(View(tth));
                    }
                    ViewBag.Message = "Clock Out time can not be earlier than Clock In time.";
                    return(View(utth));
                }
                ViewBag.Message = "Not a valid Clock In/Out time, please make sure time is in correct format.";
                return(View(utth));
            }
            ViewBag.Message = "Error inserting record.";
            return(View(new UserTimeTrackHistoryMapped()));
        }