public ActionResult EditAttWizardData([Bind(Include = "EmpDate,AttDate,EmpNo,EmpID,DutyCode,DutyTime,TimeIn,TimeOut,WorkMin,LateIn,LateOut,EarlyIn,EarlyOut,OTMin,GZOTMin,BreakMin,SLMin,StatusP,StatusAB,StatusLI,StatusLO,StatusEI,StatusEO,StatusOT,StatusGZOT,StatusGZ,StatusDO,StatusHD,StatusSL,StatusOD,StatusLeave,StatusMN,StatusIN,StatusBreak,ShifMin,ShfSplit,ProcessIn,Remarks,Tin0,Tout0,Tin1,Tout1,Tin2,Tout2,Tin3,Tout3,Tin4,Tout4,Tin5,Tout5,Tin6,Tout6,Tin7,Tout7,Tin8,Tout8,Tin9,Tout9,Tin10,Tout10,Tin11,Tout11,Tin12,Tout12,Tin13,Tout13,Tin14,Tout14,Tin15,Tout15")] AttData _attData, FormCollection form, string NewDutyCode)
        {
            string _EmpDate = _attData.EmpDate;

            ViewBag.JobCardType = new SelectList(db.JobCards, "WorkCardID", "WorkCardName");

            try
            {
                string STimeIn  = form["Inhours"].ToString();
                string STimeOut = form["OutHour"].ToString();
                if (TimeValid(STimeIn, STimeOut))
                {
                    TimeSpan _TimeIn         = new TimeSpan(0, 0, 0);
                    TimeSpan _TimeOut        = new TimeSpan(0, 0, 0);
                    TimeSpan _ThresHoldTimeS = new TimeSpan(20, 00, 00);
                    TimeSpan _ThresHoldTimeE = new TimeSpan(06, 00, 00);
                    string   date            = Request.Form["Attdate"].ToString();
                    DateTime _AttDate        = Convert.ToDateTime(date);

                    DateTime _NewTimeIn  = new DateTime();
                    DateTime _NewTimeOut = new DateTime();
                    _NewTimeIn = _AttDate + _TimeIn;
                    if (_TimeIn > _ThresHoldTimeS && _TimeOut < _ThresHoldTimeE)
                    {
                        _NewTimeOut = _AttDate.AddDays(1) + _TimeOut;
                    }
                    else
                    {
                        _NewTimeOut = _AttDate + _TimeOut;
                    }
                    int _UserID = Convert.ToInt32(Session["LogedUserID"].ToString());
                    HelperClass.MyHelper.SaveAuditLog(_UserID, (byte)MyEnums.FormName.EditAttendance, (byte)MyEnums.Operation.Edit, DateTime.Now);
                    ManualAttendanceProcess _pma = new ManualAttendanceProcess(_EmpDate, "", false, _NewTimeIn, _NewTimeOut, NewDutyCode, _UserID);
                    return(View("Index"));
                }
                else
                {
                    _attData = db.AttDatas.First(aa => aa.EmpDate == _EmpDate);
                    return(View(_attData));
                }
            }
            catch (Exception ex)
            {
                _attData = db.AttDatas.First(aa => aa.EmpDate == _EmpDate);
                return(View(_attData));
            }
        }
Exemplo n.º 2
0
        public ActionResult EditAttWizardData([Bind(Include = "EmpDate,AttDate,EmpNo,EmpID,DutyCode,DutyTime,TimeIn,TimeOut,WorkMin,LateIn,LateOut,EarlyIn,EarlyOut,OTMin,GZOTMin,BreakMin,SLMin,StatusP,StatusAB,StatusLI,StatusLO,StatusEI,StatusEO,StatusOT,StatusGZOT,StatusGZ,StatusDO,StatusHD,StatusSL,StatusOD,StatusLeave,StatusMN,StatusIN,StatusBreak,ShifMin,ShfSplit,ProcessIn,Remarks,Tin0,Tout0,Tin1,Tout1,Tin2,Tout2,Tin3,Tout3,Tin4,Tout4,Tin5,Tout5,Tin6,Tout6,Tin7,Tout7,Tin8,Tout8,Tin9,Tout9,Tin10,Tout10,Tin11,Tout11,Tin12,Tout12,Tin13,Tout13,Tin14,Tout14,Tin15,Tout15")] AttData _attData, FormCollection form, string NewDutyCode)
        {
            string _EmpDate = _attData.EmpDate;
            ViewBag.JobCardType = new SelectList(db.JobCards, "WorkCardID", "WorkCardName");

            try
            {
                string STimeIn = form["Inhours"].ToString();
                string STimeOut = form["OutHour"].ToString();
                if (TimeValid(STimeIn, STimeOut))
                {
                    TimeSpan _TimeIn = new TimeSpan(0, 0, 0);
                    TimeSpan _TimeOut = new TimeSpan(0, 0, 0);
                    TimeSpan _ThresHoldTimeS = new TimeSpan(20, 00, 00);
                    TimeSpan _ThresHoldTimeE = new TimeSpan(06, 00, 00);
                    string date = Request.Form["Attdate"].ToString();
                    DateTime _AttDate = Convert.ToDateTime(date);

                    DateTime _NewTimeIn = new DateTime();
                    DateTime _NewTimeOut = new DateTime();
                    _NewTimeIn = _AttDate + _TimeIn;
                    if (_TimeIn > _ThresHoldTimeS && _TimeOut < _ThresHoldTimeE)
                    {
                        _NewTimeOut = _AttDate.AddDays(1) + _TimeOut;
                    }
                    else
                    {
                        _NewTimeOut = _AttDate + _TimeOut;
                    }
                    int _UserID = Convert.ToInt32(Session["LogedUserID"].ToString());
                    HelperClass.MyHelper.SaveAuditLog(_UserID, (byte)MyEnums.FormName.EditAttendance, (byte)MyEnums.Operation.Edit, DateTime.Now);
                    ManualAttendanceProcess _pma = new ManualAttendanceProcess(_EmpDate, "", false, _NewTimeIn, _NewTimeOut, NewDutyCode, _UserID);
                    return View("Index");
                }
                else
                {
                    _attData = db.AttDatas.First(aa => aa.EmpDate == _EmpDate);
                    return View(_attData);
                }

            }
            catch (Exception ex)
            {
                _attData = db.AttDatas.First(aa => aa.EmpDate == _EmpDate);
                return View(_attData);
            }
        }
Exemplo n.º 3
0
        public ActionResult EditAttWizardData([Bind(Include = "EmpDate,AttDate,EmpNo,EmpID,DutyCode,DutyTime,TimeIn,TimeOut,WorkMin,LateIn,LateOut,EarlyIn,EarlyOut,OTMin,GZOTMin,BreakMin,SLMin,StatusP,StatusAB,StatusLI,StatusLO,StatusEI,StatusEO,StatusOT,StatusGZOT,StatusGZ,StatusDO,StatusHD,StatusSL,StatusOD,StatusLeave,StatusMN,StatusIN,StatusBreak,ShifMin,ShfSplit,ProcessIn,Remarks,Tin0,Tout0,Tin1,Tout1,Tin2,Tout2,Tin3,Tout3,Tin4,Tout4,Tin5,Tout5,Tin6,Tout6,Tin7,Tout7,Tin8,Tout8,Tin9,Tout9,Tin10,Tout10,Tin11,Tout11,Tin12,Tout12,Tin13,Tout13,Tin14,Tout14,Tin15,Tout15")] AttData _attData, FormCollection form, string NewDutyCode)
        {
            User LoggedInUser = Session["LoggedUser"] as User;
            string _EmpDate = _attData.EmpDate;
            ViewBag.JobCardType = new SelectList(db.JobCards.OrderBy(s=>s.WorkCardName), "WorkCardID", "WorkCardName");
            ViewBag.ShiftList = new SelectList(db.Shifts.OrderBy(s=>s.ShiftName), "ShiftID", "ShiftName");
            ViewBag.CrewList = new SelectList(db.Crews.OrderBy(s=>s.CrewName), "CrewID", "CrewName");
            ViewBag.SectionList = new SelectList(db.Sections.OrderBy(s=>s.SectionName), "SectionID", "SectionName");
            ViewBag.CompanyID = new SelectList(db.Companies, "CompID", "CompName", LoggedInUser.CompanyID);
            ViewBag.CompanyIDJobCard = new SelectList(db.Companies, "CompID", "CompName", LoggedInUser.CompanyID);
            ViewBag.DesignationID = new SelectList(db.Designations.OrderBy(s => s.DesignationName), "DesignationID", "DesignationName");
            try
            {
                string STimeIn = form["Inhours"].ToString();
                if (STimeIn.Count() < 4)
                    STimeIn = "0" + STimeIn;
                string STimeOut = form["OutHour"].ToString();
                if (STimeOut.Count() < 4)
                    STimeOut = "0" + STimeOut;
                string STimeInH = STimeIn.Substring(0, 2);
                string STimeInM = STimeIn.Substring(2, 2);
                string STimeOutH = STimeOut.Substring(0, 2);
                string STimeOutM = STimeOut.Substring(2, 2);
                string DutyTime = form["DutyTime"].ToString();
                string Remarks = form["NewRemarks"].ToString();
                string SDutyH = DutyTime.Substring(0, 2);
                string SDutyM = DutyTime.Substring(2, 2);
                string ShiftMinString = form["ShiftMinHidden"].ToString();
                if (TimeValid(STimeIn, STimeOut))
                {
                    TimeSpan _TimeIn = new TimeSpan(Convert.ToInt16(STimeInH), Convert.ToInt16(STimeInM), 0);
                    TimeSpan _TimeOut = new TimeSpan(Convert.ToInt16(STimeOutH), Convert.ToInt16(STimeOutM), 0);
                    TimeSpan _DutyTime = Convert.ToDateTime(form["DutyTime"].ToString()).TimeOfDay;
                    //TimeSpan _DutyTime = new TimeSpan(Convert.ToInt16(SDutyH), Convert.ToInt16(SDutyM), 0);
                    TimeSpan _ThresHoldTimeS = new TimeSpan(14, 00, 00);
                    TimeSpan _ThresHoldTimeE = new TimeSpan(06, 00, 00);
                    string date = Request.Form["Attdate"].ToString();
                    DateTime _AttDate = Convert.ToDateTime(date);
                    short ShiftMins = Convert.ToInt16(ShiftMinString);
                    DateTime _NewTimeIn = new DateTime();
                    DateTime _NewTimeOut = new DateTime();
                    _NewTimeIn = _AttDate + _TimeIn;
                    if (_TimeOut <_TimeIn)
                    {
                        _NewTimeOut = _AttDate.AddDays(1) + _TimeOut;
                    }
                    else
                    {
                        _NewTimeOut = _AttDate + _TimeOut;
                    }
                    int _UserID = Convert.ToInt32(Session["LogedUserID"].ToString());
                    HelperClass.MyHelper.SaveAuditLog(_UserID, (byte)MyEnums.FormName.EditAttendance, (byte)MyEnums.Operation.Edit, DateTime.Now);
                    ManualAttendanceProcess _pma = new ManualAttendanceProcess(_EmpDate, "", false, _NewTimeIn, _NewTimeOut, NewDutyCode, _UserID, _DutyTime, Remarks, ShiftMins);
                    List<PollData> _Polls = new List<PollData>();
                    _Polls = db.PollDatas.Where(aa => aa.EmpDate == _EmpDate).OrderBy(a => a.EntTime).ToList();
                    ViewBag.PollsDataIn = _Polls.Where(aa => aa.RdrDuty == 1);
                    ViewBag.PollsDataOut = _Polls.Where(aa => aa.RdrDuty == 5);
                    _attData = db.AttDatas.First(aa => aa.EmpDate == _EmpDate);
                    ViewBag.SucessMessage = "Attendance record updated.";
                    if (_attData.WorkMin != null)
                        ViewBag.WorkMin = TimeSpan.FromMinutes((double)_attData.WorkMin);
                    if (_attData.LateOut != null)
                        ViewBag.LateOut = TimeSpan.FromMinutes((double)_attData.LateOut);
                    if (_attData.LateIn != null)
                        ViewBag.LateIn = TimeSpan.FromMinutes((double)_attData.LateIn);
                    if (_attData.EarlyOut != null)
                        ViewBag.EarlyOut = TimeSpan.FromMinutes((double)_attData.EarlyOut);
                    if (_attData.EarlyIn != null)
                        ViewBag.EarlyIn = TimeSpan.FromMinutes((double)_attData.EarlyIn);
                    if (_attData.OTMin != null)
                        ViewBag.OT = TimeSpan.FromMinutes((double)_attData.OTMin);
                    if(_attData.StatusGZOT == true)
                        ViewBag.GZOT = TimeSpan.FromMinutes((double)_attData.GZOTMin);
                    return View("EditAttWizardOne", _attData);
                }
                else
                {
                    ViewBag.SucessMessage = "New Time In and New Time out is not valid";
                    _attData = db.AttDatas.First(aa => aa.EmpDate == _EmpDate);
                    return View(_attData);
                }

            }
            catch (Exception ex)
            {
                ViewBag.SucessMessage = "An error occured while saving Entry";
                _attData = db.AttDatas.First(aa => aa.EmpDate == _EmpDate);
                List<PollData> _Polls = new List<PollData>();
                _Polls = db.PollDatas.Where(aa => aa.EmpDate == _EmpDate).OrderBy(a => a.EntTime).ToList();
                ViewBag.PollsDataIn = _Polls.Where(aa => aa.RdrDuty == 1);
                ViewBag.PollsDataOut = _Polls.Where(aa => aa.RdrDuty == 5);
                return View(_attData);
            }
        }