Ejemplo n.º 1
0
        private void MarkAttendance(int empId, DateTime attendanceDate)
        {
            dsAttendance ds = new dsAttendance();

            dsAttendanceTableAdapters.AttendanceTableAdapter taAttendance = new dsAttendanceTableAdapters.AttendanceTableAdapter();
            dsAttendanceTableAdapters.EmployeeTableAdapter   taEmployee   = new dsAttendanceTableAdapters.EmployeeTableAdapter();

            taAttendance.FillByDate(ds.Attendance, attendanceDate.ToString());
            if (ds.Attendance.Rows.Count <= 0)
            {
                AttendanceList.GenerateAttendanceSheet(attendanceDate);
            }
            dsAttendanceTableAdapters.AttendanceDetailTableAdapter taAttendanceDetail = new dsAttendanceTableAdapters.AttendanceDetailTableAdapter();
            taAttendanceDetail.FillbyEmployeeDate(ds.AttendanceDetail, empId, attendanceDate.ToString());
            taEmployee.FillById(ds.Employee, empId);
            var employee         = ds.Employee.NewEmployeeRow();
            var attendanceDetail = ds.AttendanceDetail.NewAttendanceDetailRow();

            if (ds.AttendanceDetail.Rows.Count > 0)
            {
                attendanceDetail        = ds.AttendanceDetail[0];
                attendanceDetail.Status = GetStatus();
                if (ds.Employee.Rows.Count > 0)
                {
                    employee = ds.Employee[0];
                }
                if (attendanceDetail.Status == 2)
                {
                    employee.AL = employee.AL - 1;
                }
                else if (attendanceDetail.Status == 3)
                {
                    employee.CL = employee.CL - 1;
                }
                else if (attendanceDetail.Status == 4)
                {
                    employee.SL = employee.SL - 1;
                }
                if (attendanceDetail.Status == 1)
                {
                    attendanceDetail.TimeIn  = Convert.ToDateTime(dtpTimeIN.Text).TimeOfDay;
                    attendanceDetail.TimeOut = Convert.ToDateTime(dtpTimeOut.Text).TimeOfDay;
                }
                attendanceDetail.ModifiedDate = SmartManger.BAL.Common.DateNow();
                if (!attendanceDetail.IsSystemNotesNull())
                {
                    attendanceDetail.SystemNotes += "Marked by admin " + SmartManger.BAL.Common.DateNow();
                }
                else
                {
                    attendanceDetail.SystemNotes = "Modified by admin " + SmartManger.BAL.Common.DateNow();
                }
            }
            taAttendanceDetail.Update(attendanceDetail);
            taEmployee.Update(employee);
        }
Ejemplo n.º 2
0
 public static void MarkAttendanceByCamera(int empId, DateTime attendanceDate, bool isCamera)
 {
     try
     {
         dsAttendance ds = new dsAttendance();
         dsAttendanceTableAdapters.AttendanceTableAdapter taAttendance = new dsAttendanceTableAdapters.AttendanceTableAdapter();
         taAttendance.FillByDate(ds.Attendance, attendanceDate.ToString());
         if (ds.Attendance.Rows.Count <= 0)
         {
             AttendanceList.GenerateAttendanceSheet(attendanceDate);
         }
         else
         {
         }
         dsAttendanceTableAdapters.AttendanceDetailTableAdapter taAttendanceDetail = new dsAttendanceTableAdapters.AttendanceDetailTableAdapter();
         taAttendanceDetail.FillbyEmployeeDate(ds.AttendanceDetail, empId, attendanceDate.ToString());
         var attendanceDetail = ds.AttendanceDetail.NewAttendanceDetailRow();
         if (ds.AttendanceDetail.Rows.Count > 0)
         {
             attendanceDetail = ds.AttendanceDetail[0];
             if (attendanceDetail.IsTimeInNull() && isCamera == true)
             {
                 attendanceDetail.TimeIn       = (SmartManger.BAL.Common.DateNow()).TimeOfDay;
                 attendanceDetail.TimeOut      = TimeSpan.Parse("16:00:00");
                 attendanceDetail.IsByCamera   = true;
                 attendanceDetail.Status       = 1;
                 attendanceDetail.ModifiedDate = SmartManger.BAL.Common.DateNow();
                 if (!attendanceDetail.IsSystemNotesNull())
                 {
                     attendanceDetail.SystemNotes += "Marked by camerea on " + SmartManger.BAL.Common.DateNow();
                 }
                 else
                 {
                     attendanceDetail.SystemNotes = "Marked by camerea on " + SmartManger.BAL.Common.DateNow();
                 }
             }
             taAttendanceDetail.Update(attendanceDetail);
         }
         else
         {
             //MessageBox.Show("Record not Found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }