public static bool isExists(ObjSurveyRes_Layout3 obj) { string query = $@" select * from is_survey_team_layout3 where group_id = (select id from is_group where name = '{obj.group}') and discipline_id = (select id from is_discipline where name = '{obj.discipline}') "; MySqlConnection connection = DBUtils.getConnection(); connection.Open(); MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { connection.Close(); return(true); } connection.Close(); return(false); }
public static void update(ObjSurveyRes_Layout3 obj) { string query = $@" update is_survey_team_layout3 set data = '{JsonConvert.SerializeObject(obj)}' where group_id = (select id from is_group where name = '{obj.group}') and discipline_id = (select id from is_discipline where name = '{obj.discipline}') "; DBUtils.execQuery(query); }
public static void insert(ObjSurveyRes_Layout3 obj) { string query = $@" insert into is_survey_team_layout3(data, group_id, discipline_id) values ( '{JsonConvert.SerializeObject(obj)}', (select id from is_group where name = '{obj.group}'), (select id from is_discipline where name = '{obj.discipline}') ) "; DBUtils.execQuery(query); }
public static List <ObjSurveyRes_Layout3> getList(string group, string discipline) { List <ObjSurveyRes_Layout3> result = new List <ObjSurveyRes_Layout3>(); string query = $@" select result, date from is_survey where name = 'Я в команде: сильные и слабые стороны' and discipline_id = (select id from is_discipline where name = '{discipline}') and group_id = (select id from is_group where name = '{group}') "; MySqlConnection connection = DBUtils.getConnection(); connection.Open(); MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { ObjSurveyRes_Layout3 obj = new ObjSurveyRes_Layout3() { result = reader["result"].ToString(), date = reader["date"].ToString() }; result.Add(obj); } connection.Close(); return(result); }