コード例 #1
0
        private AttendanceModel Attendance_GetByEmployeeId(AttendanceModel model)
        {
            model.ResponseCode = 99;
            try
            {
                Business.HR.Attendance objAttendance = new Business.HR.Attendance();
                DataTable dt = objAttendance.Attendance_GetByEmployeeId(Convert.ToInt32(model.UserId), DateTime.UtcNow.AddHours(5).AddMinutes(33));
                if (dt != null && dt.AsEnumerable().Any())
                {
                    if (dt.Rows[0]["OutDateTime"] != null && !string.IsNullOrEmpty(dt.Rows[0]["OutDateTime"].ToString()))
                    {
                        model.CurrentState = "OUT";
                    }
                    else
                    {
                        model.CurrentState = "IN";
                    }
                }
                else
                {
                    model.CurrentState = "OUT";
                }
                model.ResponseCode = 200;
            }
            catch (Exception ex)
            {
                new Logger().LogException(ex, "Attendance_GetByEmployeeId");
                model.Message = ex.Message;
            }
            model.Message = "OUT";

            return(model);
        }
コード例 #2
0
        private void Attendance_GetByEmployeeId()
        {
            try
            {
                Business.HR.Attendance objAttendance = new Business.HR.Attendance();
                DataTable dt = objAttendance.Attendance_GetByEmployeeId(Convert.ToInt32(HttpContext.Current.User.Identity.Name), DateTime.UtcNow.AddHours(5).AddMinutes(33));
                if (dt != null && dt.AsEnumerable().Any())
                {
                    ShowLateNotification(dt);

                    if (dt.Rows[0]["OutDateTime"] != null && !string.IsNullOrEmpty(dt.Rows[0]["OutDateTime"].ToString()))
                    {
                        lnkAttendaceLogin.Visible  = true;
                        lnkAttendaceLogout.Visible = false;
                    }
                    else
                    {
                        lnkAttendaceLogin.Visible  = false;
                        lnkAttendaceLogout.Visible = true;
                    }
                }
                else
                {
                    lnkAttendaceLogin.Visible  = true;
                    lnkAttendaceLogout.Visible = false;
                }
            }
            catch (Exception ex)
            { }
        }
コード例 #3
0
        protected void gvAttendanceList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "MarkLate")
                {
                    HiddenField hdnMarkLate = (HiddenField)((GridViewRow)(((Button)e.CommandSource).NamingContainer)).FindControl("hdnMarkLate");
                    int         response    = new Business.HR.Attendance().Attendance_MarkLate(Convert.ToInt32(e.CommandArgument.ToString()), (hdnMarkLate.Value == "True") ? false : true);
                    if (response > 0)
                    {
                        MessageBox.IsSuccess = true;
                        MessageBox.Text      = "Marked sucessfully.";
                        Attendance_GetAll();
                    }
                    else
                    {
                        MessageBox.IsSuccess = false;
                        MessageBox.Text      = "Failed to mark.";
                    }
                }
                else if (e.CommandName == "MarkHalfDay")
                {
                    HiddenField hdnMarkHalfday = (HiddenField)((GridViewRow)((Button)e.CommandSource).NamingContainer).FindControl("hdnMarkHalfday");
                    int         response       = new Business.HR.Attendance().Attendance_MarkHalfday(Convert.ToInt32(e.CommandArgument.ToString()), (hdnMarkHalfday.Value == "True") ? false : true);
                    if (response > 0)
                    {
                        MessageBox.IsSuccess = true;
                        MessageBox.Text      = "Marked sucessfully.";
                        Attendance_GetAll();
                    }
                    else
                    {
                        MessageBox.IsSuccess = false;
                        MessageBox.Text      = "Failed to mark.";
                    }
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                MessageBox.IsSuccess = false;
                MessageBox.Text      = ex.Message;
            }
            finally
            {
                MessageBox.Show = true;
            }
        }
コード例 #4
0
        private void Attendance_GetAll()
        {
            DataSet dsAttendance =
                new Business.HR.Attendance()
                .Attendance_GetAll(new Entity.HR.Attendance()
            {
                EmployeeName       = txtEmployeeName.Text.Trim(),
                AttendanceFromDate = (string.IsNullOrEmpty(txtFromAttendanceDate.Text.Trim())) ? DateTime.MinValue : Convert.ToDateTime(txtFromAttendanceDate.Text.Trim()),
                AttendanceToDate   = (string.IsNullOrEmpty(txtToAttendanceDate.Text.Trim())) ? DateTime.MinValue : Convert.ToDateTime(txtToAttendanceDate.Text.Trim()),
                PageIndex          = gvAttendanceList.PageIndex,
                PageSize           = gvAttendanceList.PageSize
            });

            if (dsAttendance.Tables.Count > 1)
            {
                gvAttendanceList.DataSource       = dsAttendance;
                gvAttendanceList.VirtualItemCount = (dsAttendance.Tables[1].Rows.Count > 0) ? Convert.ToInt32(dsAttendance.Tables[1].Rows[0]["TotalCount"].ToString()) : 10;
                gvAttendanceList.DataBind();
            }
        }
コード例 #5
0
        private List <Models.AttendanceModel> Attendance_CurrentMonth_GetByEmployeeId(int employeeId)
        {
            List <Models.AttendanceModel> model = new List <Models.AttendanceModel>();
            DataTable dtAttendance = new Business.HR.Attendance().Attendance_CurrentMonth_GetByEmployeeId(employeeId, DateTime.Now.Month, DateTime.Now.Year);

            if (dtAttendance != null &&
                dtAttendance.AsEnumerable().Any())
            {
                foreach (DataRow dr in dtAttendance.Rows)
                {
                    model.Add(new Models.AttendanceModel
                    {
                        AttendanceInDate  = string.Format("Attendance In-Date & Time: {0}", dr["InDateTime"].ToString()),
                        AttendanceOutDate = string.Format("Attendance Out-Date & Time: {0}", dr["OutDateTime"].ToString()),
                        TotalWorkingHours = string.Format("Working Hours: {0}", dr["TotalHours"].ToString()),
                        IsLate            = string.Format("Late: {0}", dr["IsLate"].ToString()),
                        IsLateReduced     = string.Format("Leave reduced: {0}", dr["IsLateReduced"].ToString()),
                        IsHalfDay         = string.Format("Half day: {0}", dr["IsHalfday"].ToString())
                    });
                }
            }

            return(model);
        }
コード例 #6
0
 private AttendanceModel SaveAttendance(AttendanceModel model)
 {
     model.ResponseCode = 99;
     try
     {
         if (!CheckAttendanceBlocked(model))
         {
             if (model.AttendanceMode.ToLower().Equals("out"))
             {
                 Business.HR.Attendance objAttendance = new Business.HR.Attendance();
                 Entity.HR.Attendance   attendance    = new Entity.HR.Attendance()
                 {
                     AttendanceDate = DateTime.UtcNow.AddHours(5).AddMinutes(33),
                     InDateTime     = DateTime.UtcNow.AddHours(5).AddMinutes(33),
                     OutDateTime    = DateTime.UtcNow.AddHours(5).AddMinutes(33),
                     EmployeeId     = Convert.ToInt32(model.UserId),
                     CreatedBy      = Convert.ToInt32(model.UserId),
                     TotalHours     = 0,
                     Latitude       = model.Latitude,
                     Longitude      = model.Longitude,
                     Source         = "Android"
                 };
                 objAttendance.Attendance_Save(attendance);
                 model.Message      = "You are successfully IN.";
                 model.ResponseCode = 200;
             }
             else if (model.AttendanceMode.ToLower().Equals("in"))
             {
                 Business.HR.Attendance objAttendance = new Business.HR.Attendance();
                 DataTable dt = objAttendance.Attendance_GetByEmployeeId(Convert.ToInt32(model.UserId), DateTime.UtcNow.AddHours(5).AddMinutes(33));
                 if (dt != null && dt.AsEnumerable().Any())
                 {
                     Entity.HR.Attendance attendance = new Entity.HR.Attendance()
                     {
                         AttendanceId   = Convert.ToInt64(dt.Rows[0]["AttendanceId"].ToString()),
                         AttendanceDate = Convert.ToDateTime(dt.Rows[0]["AttendanceDate"].ToString()),
                         InDateTime     = Convert.ToDateTime(dt.Rows[0]["InDateTime"].ToString()),
                         OutDateTime    = DateTime.UtcNow.AddHours(5).AddMinutes(33),
                         CreatedBy      = Convert.ToInt32(model.UserId),
                         TotalHours     = (DateTime.UtcNow.AddHours(5).AddMinutes(33) - Convert.ToDateTime(dt.Rows[0]["InDateTimeRaw"].ToString())).TotalMinutes,
                         Latitude       = model.Latitude,
                         Longitude      = model.Longitude,
                         Source         = "Android"
                     };
                     objAttendance.Attendance_Save(attendance);
                     model.Message      = "You are successfully OUT.";
                     model.ResponseCode = 200;
                 }
                 else
                 {
                     model.Message      = "Invalid employee id.";
                     model.ResponseCode = 200;
                 }
             }
         }
         else
         {
             model.Message      = "Your attendance is blocked for today. Please contact HR.";
             model.ResponseCode = 200;
         }
     }
     catch (Exception ex)
     {
         new Logger().LogException(ex, "SaveAttendance");
         model.ResponseCode = 99;
         model.Message      = ex.Message;
     }
     return(model);
 }