public static void AddBank(bank_master mst) { try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { string query = "INSERT INTO bank_master (bank_id,bank_name) VALUES (@bank_id,@bank_name)"; string maxid = @"SELECT IFNULL(MAX(bank_id), 0) + 1 FROM bank_master"; int id = con.ExecuteScalar <int>(maxid); mst.bank_id = id; mst.bank_name = mst.bank_name.Trim(); con.Execute(query, new { mst.bank_id, mst.bank_name }); } } catch (Exception ex) { throw ex; } }
public static void EditBank(bank_master mst) { try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { string query = @"UPDATE bank_master SET bank_name = @bank_name WHERE bank_id = @bank_id"; con.Execute(query, mst); } } catch (Exception ex) { throw ex; } }