public string Add_CTNgoaiNgu(Cls_CTNgoaiNgu ctnn) { string strMessage = string.Empty; using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); SqlCommand cmd = new SqlCommand("insert into Tb_CTNgoaiNgu (MaCTNN,MaNN,MaNV,TrinhDo,NgayCap,NoiCap) values(@MACTNN,@MANN,@MANV,@TRINHDO,@NGAYCAP,@NOICAP)", conn); cmd.Parameters.AddWithValue("@MACTNN", ctnn.mactnn); cmd.Parameters.AddWithValue("@MANN", ctnn.mann); cmd.Parameters.AddWithValue("@MANV", ctnn.manv); cmd.Parameters.AddWithValue("@TRINHDO", ctnn.trinhdo); cmd.Parameters.AddWithValue("@NGAYCAP", ctnn.ngaycap); cmd.Parameters.AddWithValue("@NOICAP", ctnn.noicap); int result = cmd.ExecuteNonQuery(); if (result == 1) { strMessage = ctnn.mactnn + " đã thêm thành công!"; } else { strMessage = ctnn.mactnn + " đã thêm không thành công!"; } conn.Close(); } return strMessage; }
public string Delete_CTNgoaiNgu(Cls_CTNgoaiNgu ctnn) { string strMessage = string.Empty; using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); SqlCommand cmd = new SqlCommand("delete Tb_CTNgoaiNgu where MaCTNN=@MACTNN", conn); cmd.Parameters.AddWithValue("@MACTNN", ctnn.mactnn); int result = cmd.ExecuteNonQuery(); if (result == 1) { strMessage = ctnn.mactnn + " đã delete thành công!"; } else { strMessage = ctnn.mactnn + " delete không thành công!"; } conn.Close(); } return strMessage; }
public string Update_CTNgoaiNgu(Cls_CTNgoaiNgu ctnn) { string strMessage = string.Empty; using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); SqlCommand cmd = new SqlCommand("update Tb_CTNgoaiNgu set MaNN=@MANN,MaNV=@MANV,TrinhDo=@TRINHDO,NgayCap=@NGAYCAP,NoiCap=@NOICAP where MaCTNN=@MACTNN", conn); cmd.Parameters.AddWithValue("@MACTNN", ctnn.mactnn); cmd.Parameters.AddWithValue("@MANN", ctnn.mann); cmd.Parameters.AddWithValue("@MANV", ctnn.manv); cmd.Parameters.AddWithValue("@TRINHDO", ctnn.trinhdo); cmd.Parameters.AddWithValue("@NGAYCAP", ctnn.ngaycap); cmd.Parameters.AddWithValue("@NOICAP", ctnn.noicap); int result = cmd.ExecuteNonQuery(); if (result == 1) { strMessage = ctnn.mactnn + " đã update thành công!"; } else { strMessage = ctnn.mactnn + " update không thành công!"; } conn.Close(); } return strMessage; }