public ResponseMessage UpdateAttendance(TblAttendance attendance)
        {
            ResponseMessage result    = new ResponseMessage();
            int             sqlResult = 0;

            try
            {
                using (_connection = new OracleConnection(_dbConnectionString))
                {
                    using (_command = new OracleCommand())
                    {
                        _command.BindByName = true;
                        _command.Connection = _connection;
                        _connection.Open();
                        _command.CommandText = "spUpdateAttendance";
                        _command.Parameters.Add("p_id", attendance.ID);
                        _command.Parameters.Add("p_check_in", attendance.CHECK_IN);
                        _command.Parameters.Add("p_check_out", attendance.CHECK_OUT);
                        _command.Parameters.Add("p_status", attendance.STATUS);
                        _command.CommandType = CommandType.StoredProcedure;
                        sqlResult            = _command.ExecuteNonQuery();
                        _connection.Close();
                    }
                }
                return(result = ResponseMapping.GetResponseMessage(sqlResult, (int)StatusCode.Success, ConstantMessage.UpdateAttendanceSuccess));
            }
            catch (Exception ex)
            {
                return(result = ResponseMapping.GetResponseMessage(null, (int)StatusCode.Faild, ex.Message.ToString()));
            }
        }
        public ResponseMessage CheckIN(TblAttendance attendance)
        {
            ResponseMessage result    = new ResponseMessage();
            int             sqlResult = 0;

            try
            {
                using (_connection = new OracleConnection(_dbConnectionString))
                {
                    using (_command = new OracleCommand())
                    {
                        _command.BindByName = true;
                        _command.Connection = _connection;
                        _connection.Open();
                        _command.CommandText = "spCheckIn";
                        _command.Parameters.Add("p_employee_id", attendance.EMPLOYEE_ID);
                        _command.Parameters.Add("p_latitude", attendance.LATITUDE);
                        _command.Parameters.Add("p_longitude", attendance.LONGITUDE);
                        _command.CommandType = CommandType.StoredProcedure;
                        sqlResult            = _command.ExecuteNonQuery();
                        _connection.Close();
                    }
                }
                return(result = ResponseMapping.GetResponseMessage(sqlResult, (int)StatusCode.Success, ConstantMessage.CheckInSuccess));
            }
            catch (Exception ex)
            {
                return(result = ResponseMapping.GetResponseMessage(null, (int)StatusCode.Faild, ex.Message.ToString()));
            }
        }
Esempio n. 3
0
        public ActionResult List(TblAttendance am, string Date, int[] StudentId)
        {
            for (int i = 0; i < StudentId.Length; i++)
            {
                am.S_Id = StudentId[i];

                db.TblAttendances.Add(am);
                db.SaveChanges();
            }

            return(Content("Done"));
        }
        public ResponseMessage GetAttendanceByDate(int id, DateTime startDate, DateTime endDate)
        {
            ResponseMessage      result         = new ResponseMessage();
            List <TblAttendance> attendanceList = new List <TblAttendance>();

            try
            {
                using (_connection = new OracleConnection(_dbConnectionString))
                {
                    using (_command = new OracleCommand())
                    {
                        _command.BindByName = true;
                        _connection.Open();
                        _command.Connection = _connection;

                        _command.CommandText = "spSearchByDate";
                        _command.Parameters.Add("p_id", id);
                        _command.Parameters.Add("start_date", startDate);
                        _command.Parameters.Add("end_date", endDate);
                        _command.Parameters.Add("EMP_ATTEN_CURSOR", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                        _command.CommandType = CommandType.StoredProcedure;
                        _reader = _command.ExecuteReader();

                        while (_reader.Read())
                        {
                            TblAttendance attendance = new TblAttendance();

                            attendance.ID            = Convert.ToInt32(_reader["ID"]);
                            attendance.EMPLOYEE_ID   = id;
                            attendance.DATE_TIME     = Convert.ToDateTime(_reader["DATE_TIME"]);
                            attendance.CHECK_IN      = Convert.ToDateTime(_reader["CHECK_IN"]);
                            attendance.CHECK_OUT     = Convert.ToDateTime(_reader["CHECK_OUT"]);
                            attendance.LATE_DURATION = Convert.ToInt32(_reader["LATE_DURATION"]);
                            attendance.STATUS        = _reader["STATUS"].ToString();

                            attendanceList.Add(attendance);
                        }

                        _connection.Close();
                    }
                }


                return(result = ResponseMapping.GetResponseMessage(attendanceList, (int)StatusCode.Success, ConstantMessage.RetriveSuccess));
            }
            catch (Exception ex)
            {
                return(result = ResponseMapping.GetResponseMessage(null, (int)StatusCode.Faild, ex.Message.ToString()));
            }
        }
        public ResponseMessage GetAllAttendance()
        {
            ResponseMessage      result         = new ResponseMessage();
            List <TblAttendance> attendanceList = new List <TblAttendance>();

            try
            {
                using (_connection = new OracleConnection(_dbConnectionString))
                {
                    using (_command = new OracleCommand())
                    {
                        _connection.Open();
                        _command.Connection = _connection;

                        _command.CommandText = "sp_FetchAllAttendance";
                        _command.Parameters.Add("attendance_cursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

                        _command.CommandType = CommandType.StoredProcedure;
                        _reader = _command.ExecuteReader();

                        while (_reader.Read())
                        {
                            TblAttendance attendance = new TblAttendance();

                            attendance.ID            = Convert.ToInt32(_reader["ID"]);
                            attendance.DATE_TIME     = Convert.ToDateTime(_reader["DATE_TIME"].ToString());
                            attendance.CHECK_IN      = Convert.ToDateTime(_reader["CHECK_IN"]);
                            attendance.CHECK_OUT     = (!string.IsNullOrEmpty(_reader["CHECK_OUT"].ToString())) ? Convert.ToDateTime(_reader["CHECK_OUT"]) : null;
                            attendance.LATE_DURATION = Convert.ToInt32(_reader["LATE_DURATION"]);
                            attendance.STATUS        = _reader["STATUS"].ToString();
                            attendance.LATITUDE      = Convert.ToDouble(_reader["LATITUDE"]);
                            attendance.LONGITUDE     = Convert.ToDouble(_reader["LONGITUDE"]);

                            attendanceList.Add(attendance);
                        }

                        _connection.Close();
                    }
                }


                return(result = ResponseMapping.GetResponseMessage(attendanceList, (int)StatusCode.Success, ConstantMessage.RetriveSuccess));
            }
            catch (Exception ex)
            {
                return(result = ResponseMapping.GetResponseMessage(null, (int)StatusCode.Faild, ex.Message.ToString()));
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            CheckBox    chk = null;
            HiddenField hfStudentID = null, hfClassNo = null;
            bool        IsPresent = true;

            for (int i = 0; i < rptStudents.Items.Count; i++)
            {
                chk         = (CheckBox)rptStudents.Items[i].FindControl("chkAll");
                hfStudentID = (HiddenField)rptStudents.Items[i].FindControl("hfStudentID");
                //hfClassNo.Value = ;

                if (chk.Checked)
                {
                    IsPresent = true;
                }
                else
                {
                    IsPresent = false;
                }

                TblAttendance obj = new TblAttendance();
                obj.IsNew = true;

                if (AttendaceID.Count != 0)
                {
                    obj       = new TblAttendance(AttendaceID[i]);
                    obj.IsNew = false;
                }

                obj.BranchID       = Convert.ToInt32(Session["BranchID"]);
                obj.StudentID      = Convert.ToInt32(hfStudentID.Value);
                obj.ClassNo        = Convert.ToInt32(ddlClass.SelectedValue);
                obj.AttendanceDate = helper.getDateTime();
                obj.IsPresent      = IsPresent;
                obj.Updateby       = Session["BranchUserName"].ToString();
                obj.Save();
            }

            if (ddlClass.Items.Count > 1 && !String.IsNullOrEmpty(ddlClass.SelectedValue))
            {
                DataTable dt          = helper.ExecutePlainQuery("select * from TblStudents inner join tbl_Attendance on TblStudents.StudentID=tbl_Attendance.StudentID where CONVERT(date, AttendanceDate)=CONVERT(date,'" + helper.getDateTime() + "') and TblStudents.BranchID=" + Session["BranchID"] + " and tbl_Attendance.ClassNo=" + ddlClass.SelectedValue);
                string    Student     = null;
                string    Description = null;
                string    Contact     = null;
                for (int i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    if (dt.Rows.Count > 0)
                    {
                        IsPresent = Convert.ToBoolean(dt.Rows[i]["IsPresent"]);
                        if (!IsPresent)
                        {
                            if (dt.Rows[i]["Gender"].ToString() == "Male")
                            {
                                Student = "Son";
                            }
                            else
                            {
                                Student = "Daughter";
                            }
                            Description = "Dear " + dt.Rows[i]["GName"] + "sir! your " + Student + " is absent today! Regards: Pak Paerl school & colleges(" + Session["BranchUserName"] + ")";
                            Contact     = dt.Rows[i]["GCellNo"].ToString();
                            SendSms.SendMessage(Contact, Description);
                        }
                    }
                }
            }

            AttendaceID.Clear();
            ddlClass.Items.Clear();
            ddlGroups.Items.Clear();
            ddlLevel.SelectedValue = "";
            // lblmsg.Text = helper.DisplayNotificationMessage(msgDiv, "", "alert alert-success alert-icon alert-dismissible", icon, "icon mdi mdi-check");
            Response.Redirect("ManageAttendance.aspx?msg=" + helper.Encrypt("Attendance has been submited!"));
            LoadStudents();
        }
Esempio n. 7
0
        public JsonResult CheckIn([FromForm] TblAttendance attendance)
        {
            var resuslt = _employeeServices.CheckIN(attendance);

            return(new JsonResult(resuslt));
        }
Esempio n. 8
0
        public JsonResult UpdateAttendance([FromForm] TblAttendance attendance)
        {
            var resuslt = _employeeServices.UpdateAttendance(attendance);

            return(new JsonResult(resuslt));
        }