Ejemplo n.º 1
0
        public ActionResult TimeSheetAuthorizedSaved(string ButtonType, TimeSheetBO timeSheetBO)
        {
            //timeSheetBO.NoOFShift = Convert.ToInt16(TempData["TotalShift" + timeSheetBO.ResourcesID.ToString()]);
            //timeSheetBO.TolShiftHrs = Convert.ToInt64(TempData["TotalShiftHrs" + timeSheetBO.ResourcesID.ToString()]);
            //timeSheetBO.TolHly = Convert.ToDouble(TempData["TotalHly" + timeSheetBO.ResourcesID.ToString()]);
            //timeSheetBO.TolHlyHours = Convert.ToDouble(TempData["TotalHlytHours" + timeSheetBO.ResourcesID.ToString()]);
            timeSheetBO.Payment = Convert.ToInt64(TempData["Payment" + timeSheetBO.ResourcesID.ToString()]);

            DateTime StatusDate;
            string   Msg, status = "";

            if (timeSheetBL.TimeSheetAuthorizedFun(timeSheetBO, out Msg, ButtonType, out status, out StatusDate))
            {
                return(Json(new { success = true, errorMsg = Msg, AuthoStatus = status, AuthoStatusDate = StatusDate }));
            }
            else
            {
                return(Json(new { success = false, errorMsg = Msg, AuthoStatus = status, AuthoStatusDate = StatusDate }));
            }
        }
Ejemplo n.º 2
0
        public ActionResult TimeSheet(TimeSheetView timeSheetView)
        {
            // = new TimeSheetView();
            TempData["TimeSerachBO"] = timeSheetView.TsearchBBO;
            if (TempData["TimeSerachBO"] != null)
            {
                timeSheetView.TsearchBBO = TempData["TimeSerachBO"] as TimeSearchBO;
            }
            else
            {
                timeSheetView.TsearchBBO         = new TimeSearchBO();
                timeSheetView.TsearchBBO.MonthID = DateTime.Now.Month;
                timeSheetView.TsearchBBO.Year    = DateTime.Now.Year.ToString();
            }
            viewBagList();

            TimeSheetBO timeSheetBO   = new TimeSheetBO();
            var         timeSheetList = timeSheetBL.GetfilterTimeSheet(timeSheetView.TsearchBBO);

            timeSheetView.timeSheetBBO  = new TimeSheetBO();
            timeSheetView.timeSheetView = timeSheetList;
            TempData["TimeSerachBO"]    = timeSheetView.TsearchBBO;
            return(View(timeSheetView));
        }
Ejemplo n.º 3
0
        //Authorized & UnAuthorized the Timesheet Resources Details
        public bool TimeSheetAuthorizedFun(TimeSheetBO timeSheetBO, out string Msg, string ButtonType, out string status, out DateTime StatusDate)
        {
            Msg = "";
            // Authorized
            if (ButtonType == "Authorized")
            {
                if (timeSheetBO.TimesheetID == null)
                {
                    try
                    {
                        Resource_TimeSheet authorized = new Resource_TimeSheet();

                        authorized.ResourceID                 = db.Resource_Employee.Where(x => x.EmployeeID == timeSheetBO.ResourcesID).Select(x => x.EmployeeID).FirstOrDefault();
                        authorized.TimeSheetDate              = (DateTime)(timeSheetBO.TimeSheetDate == null ? timeSheetBO.dtDethTime1 :timeSheetBO.TimeSheetDate);
                        authorized.TimeSheetFrequencyID       = db.Common_TimeSheetFrequency.Where(x => x.TimeSheetFrequencyID == timeSheetBO.FrequencyID).Select(x => x.TimeSheetFrequencyID).FirstOrDefault();
                        authorized.TimeSheetAuthorizationDate = DateTime.Now;
                        authorized.Approved         = "Yes";
                        authorized.LockedBy         = HttpContext.Current.User.Identity.Name;
                        authorized.LockedDateTime   = DateTime.Now;
                        authorized.Comments         = "No Comments ";
                        authorized.NoOfShift        = timeSheetBO.NoOFShift;
                        authorized.TotalShiftHours  = (double)(timeSheetBO.TolShiftHrs == null ? 0: timeSheetBO.TolShiftHrs);
                        authorized.NoOfHolidays     = (double)(timeSheetBO.TolHly == null ? 0 : timeSheetBO.TolHly);
                        authorized.NoOfHolidayHours = (double)(timeSheetBO.TolHlyHours == null ? 0 : timeSheetBO.TolHlyHours);
                        authorized.IsAct            = true;
                        authorized.Payment          = (double)timeSheetBO.Payment;
                        db.Resource_TimeSheet.Add(authorized);
                        db.SaveChanges();
                        Msg        = "Timesheet Is Successfully Authorized For  " + timeSheetBO.TimeSheetDate + " Date";
                        status     = "Authorized";
                        StatusDate = DateTime.Now;
                        return(true);
                    }

                    catch (Exception e)
                    {
                        StatusDate = DateTime.Now;
                        status     = timeSheetBO.Status;
                        Msg        = e.Message;
                        return(false);
                    }
                }
                else
                {
                    //Re Authorized
                    var isExitTimesheet = db.Resource_TimeSheet.Where(x => x.TimeSheetID == timeSheetBO.TimesheetID && x.TimeSheetAuthorizationDate == null).SingleOrDefault();
                    if (isExitTimesheet != null)
                    {
                        try
                        {
                            isExitTimesheet.ResourceID                 = db.Resource_Employee.Where(x => x.EmployeeID == timeSheetBO.ResourcesID).Select(x => x.EmployeeID).FirstOrDefault();
                            isExitTimesheet.TimeSheetDate              = (DateTime)(timeSheetBO.TimeSheetDate == null ? timeSheetBO.dtDethTime1 : timeSheetBO.TimeSheetDate);
                            isExitTimesheet.TimeSheetFrequencyID       = db.Common_TimeSheetFrequency.Where(x => x.TimeSheetFrequencyID == timeSheetBO.FrequencyID).Select(x => x.TimeSheetFrequencyID).FirstOrDefault();
                            isExitTimesheet.TimeSheetAuthorizationDate = DateTime.Now;
                            isExitTimesheet.Approved         = "Yes";
                            isExitTimesheet.LockedBy         = HttpContext.Current.User.Identity.Name;
                            isExitTimesheet.LockedDateTime   = DateTime.Now;
                            isExitTimesheet.Comments         = "No Comments ";
                            isExitTimesheet.NoOfShift        = timeSheetBO.NoOFShift;
                            isExitTimesheet.TotalShiftHours  = (double)(timeSheetBO.TolShiftHrs == null ? 0 : timeSheetBO.TolShiftHrs);
                            isExitTimesheet.NoOfHolidays     = (double)(timeSheetBO.TolHly == null ? 0 : timeSheetBO.TolHly);
                            isExitTimesheet.NoOfHolidayHours = (double)(timeSheetBO.TolHlyHours == null ? 0 : timeSheetBO.TolHlyHours);
                            isExitTimesheet.IsAct            = true;
                            isExitTimesheet.Payment          = (double)timeSheetBO.Payment;

                            db.SaveChanges();
                            Msg        = "Timesheet Is Successfully Authorized For  " + timeSheetBO.TimeSheetDate + " Date ";
                            status     = "Authorized";
                            StatusDate = DateTime.Now;
                            return(true);
                        }

                        catch (Exception e)
                        {
                            status     = timeSheetBO.Status;
                            Msg        = e.Message;
                            StatusDate = DateTime.Now;
                            return(false);
                        }
                    }
                    else
                    {
                        Msg        = " Timesheet Is Already Authorized For " + db.Resource_TimeSheet.Where(x => x.ResourceID == timeSheetBO.ResourcesID && x.TimeSheetDate.Month == timeSheetBO.MonthID).Select(x => x.TimeSheetDate).SingleOrDefault() + "Date";
                        status     = timeSheetBO.Status;
                        StatusDate = DateTime.Now;
                        return(false);
                    }
                }
            }
            //UnAuthorized The Resources Details
            else
            {
                var isExitUnAuzedTimesheet = db.Resource_TimeSheet.SingleOrDefault(x => x.TimeSheetID == timeSheetBO.TimesheetID && x.TimeSheetAuthorizationDate != null);
                if (isExitUnAuzedTimesheet != null)
                {
                    try
                    {
                        isExitUnAuzedTimesheet.TimeSheetAuthorizationDate = null;
                        isExitUnAuzedTimesheet.IsAct = false;

                        db.SaveChanges();
                        Msg        = "Timesheet Is Successfully UnAuthorized  For" + timeSheetBO.TimeSheetDate + "Date";
                        status     = "UnAuthorized";
                        StatusDate = DateTime.Now;
                        return(true);
                    }
                    catch (Exception e)
                    {
                        status     = timeSheetBO.Status;
                        Msg        = e.Message;
                        StatusDate = DateTime.Now;
                        return(false);
                    }
                }
                // Fail UnAuthorized
                else
                {
                    status     = timeSheetBO.Status;
                    Msg        = "Timesheet Is Already UnAuthorized For" + timeSheetBO.TimeSheetDate + "Date";
                    StatusDate = DateTime.Now;
                    return(false);
                }
            }
        }