public static void checkEmployeesAsAbsent() { MySqlConnection conn = Connection.getConnection(); List <bool> attandanceList = new List <bool>(); List <int> attandanceCountList = new List <int>(); List <int> overTimeList = new List <int>(); List <int> userIdList = new List <int>(); List <string> leavesCountList = new List <string>(); try { conn.Open(); MySqlCommand command = new MySqlCommand("SELECT * FROM shophope.employeetable", conn); MySqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { attandanceCountList.Add(int.Parse(dataReader.GetString("monthlyAttandance"))); userIdList.Add(int.Parse(dataReader.GetString("userId"))); overTimeList.Add(int.Parse(dataReader.GetString("todayOverTime")) + int.Parse(dataReader.GetString("overTime"))); leavesCountList.Add(dataReader.GetString("leavesPerMonth")); if (dataReader.GetString("presence").Equals("t")) { attandanceList.Add(true); } else { attandanceList.Add(false); } } } catch (Exception ex) { Console.WriteLine("error occured at stock manager weight combo " + ex.Message); } finally { conn.Close(); } for (int i = 0; i < attandanceList.Count; i++) { if (attandanceList[i]) { try { conn = Connection.getConnection(); conn.Open(); MySqlCommand command = new MySqlCommand("UPDATE shophope.employeetable SET monthlyAttandance = '" + (attandanceCountList[i] + 1).ToString() + "', overTime = '" + overTimeList[i].ToString() + "',todayOverTime = '0', presence = 'f' WHERE userId = '" + userIdList[i].ToString() + "'", conn); MySqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { } } catch (Exception ex) { Console.WriteLine("error occured at stock manager weight combo " + ex.Message); } finally { conn.Close(); } } else { try { conn = Connection.getConnection(); conn.Open(); MySqlCommand command = new MySqlCommand("UPDATE shophope.employeetable SET leavesPerMonth = '" + (int.Parse(leavesCountList[i]) + 1).ToString() + "',todayOverTime = '0' WHERE userId = '" + userIdList[i].ToString() + "'", conn); MySqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { } } catch (Exception ex) { Console.WriteLine("error occured at stock manager weight combo " + ex.Message); } finally { conn.Close(); } } } }