public JsonResult GetEmployeeID(string AttendanceID) { List <AbsencesAndTardiness> t = new List <AbsencesAndTardiness>(); string conn = ConfigurationManager.ConnectionStrings["kalingaPPDO"].ConnectionString; using (SqlConnection cn = new SqlConnection(conn)) { string myQuery = "SELECT * FROM rep_AbsencesTardinessDetailsPerEmployee2 where empAttendanceMainID = @AttendanceID"; SqlCommand cmd = new SqlCommand() { CommandText = myQuery, CommandType = CommandType.Text }; cmd.Parameters.AddWithValue("@AttendanceID", AttendanceID); cmd.Connection = cn; cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { int counter = 0; while (dr.Read()) { AbsencesAndTardiness tsData = new AbsencesAndTardiness() { empID = dr["empID"].ToString() }; t.Add(tsData); counter++; } } } return(Json(t, JsonRequestBehavior.AllowGet)); }
public JsonResult PerEmployee(int empID, int AttendanceID) { List <AbsencesAndTardiness> t = new List <AbsencesAndTardiness>(); string conn = ConfigurationManager.ConnectionStrings["kalingaPPDO"].ConnectionString; using (SqlConnection cn = new SqlConnection(conn)) { string myQuery = "SELECT * FROM rep_AbsencesTardinessDetailsPerEmployee2 where empAttendanceMainID = @AttendanceID AND empID = @empID"; SqlCommand cmd = new SqlCommand() { CommandText = myQuery, CommandType = CommandType.Text }; cmd.Parameters.AddWithValue("@AttendanceID", AttendanceID); cmd.Parameters.AddWithValue("@empID", empID); cmd.Connection = cn; cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { int counter = 0; while (dr.Read()) { AbsencesAndTardiness tsData = new AbsencesAndTardiness() { empAttendanceMainID = dr["empAttendanceMainID"].ToString(), NameDate = dr["NameDate"].ToString(), DTRDate = dr["DTRDate"].ToString(), empID = dr["empID"].ToString(), LOGIN = dr["LOGIN"].ToString(), LOGOUT = dr["LOGOUT"].ToString(), AbsHrs = dr["AbsHrs"].ToString(), AbsHrsDec = dr["AbsHrsDec"].ToString(), LateHrs = dr["LateHrs"].ToString(), LateHrsDec = dr["LateHrsDec"].ToString(), UnderTimeHours = dr["UnderTimeHours"].ToString(), UnderTimeHoursDec = dr["UnderTimeHoursDec"].ToString(), LeaveTypeCode = dr["LeaveTypeCode"].ToString(), OTHrs = dr["OTHrs"].ToString(), OTHrsDec = dr["OTHrsDec"].ToString(), }; t.Add(tsData); counter++; } } } return(Json(t, JsonRequestBehavior.AllowGet)); }