public void EditClass(mst_class mst) { try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { string query = @"UPDATE mst_class SET class_name = @class_name WHERE class_id = @class_id AND session = (SELECT session FROM mst_session WHERE session_active = 'Y')"; con.Execute(query, mst); } } catch (Exception ex) { throw ex; } }
public void AddClass(mst_class mst) { try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { mst_sessionMain session = new mst_sessionMain(); string sess = session.findActive_Session(); string query = "INSERT INTO mst_class (session,class_id,class_name) VALUES (@session,@class_id,@class_name)"; string maxid = @"SELECT IFNULL(MAX(class_id), 0) + 1 FROM mst_class WHERE session = (SELECT session FROM mst_session WHERE session_active = 'Y')"; // var id = con.Query<mst_section>(maxid).ToString().Trim(); int id = con.ExecuteScalar <int>(maxid); mst.class_id = id; mst.class_name = mst.class_name.Trim(); con.Execute(query, new { session = sess, mst.class_id, mst.class_name }); } } catch (Exception ex) { throw ex; } }