Exemple #1
0
 public int InsertKhoa(Khoa kh)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         var          str = "insert into KHOA values(@makhoa, @tenkhoa)";
         MySqlCommand cmd = new MySqlCommand(str, conn);
         cmd.Parameters.AddWithValue("makhoa", kh.MaKhoa);
         cmd.Parameters.AddWithValue("tenkhoa", kh.TenKhoa);
         return(cmd.ExecuteNonQuery());
     }
 }
Exemple #2
0
 public int UpdateKhoa(Khoa kh)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         var          str = "update KHOA set TenKhoa = @tenkhoa where MaKhoa=@makhoa";
         MySqlCommand cmd = new MySqlCommand(str, conn);
         cmd.Parameters.AddWithValue("tenkhoa", kh.TenKhoa);
         cmd.Parameters.AddWithValue("makhoa", kh.MaKhoa);
         return(cmd.ExecuteNonQuery());
     }
 }
Exemple #3
0
        public Khoa ViewKhoa(string Id)
        {
            //Khoa kh = new Khoa("MK01","HTTT");
            Khoa kh = new Khoa();

            using (MySqlConnection conn = GetConnection())
            {
                conn.Open();
                var          str = "select * from KHOA where MaKhoa=@makhoa";
                MySqlCommand cmd = new MySqlCommand(str, conn);
                cmd.Parameters.AddWithValue("makhoa", Id);
                using (var reader = cmd.ExecuteReader())
                {
                    reader.Read();
                    kh.MaKhoa  = reader["MaKhoa"].ToString();
                    kh.TenKhoa = reader["TenKhoa"].ToString();
                }
            }
            return(kh);
        }