public string Add_CTHopDong(Cls_CTHopDong cthd) { string strMessage = string.Empty; using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); SqlCommand cmd = new SqlCommand("set dateformat dmy insert into Tb_CTHopDong (SoHD,MaLoaiHD,MaNV,NgayBatDau,NgayKetThuc,LuongCB) values(@SOHD,@MALOAIHD,@MANV,@NGAYBATDAU,@NGAYKETTHUC,@LUONGCB)", conn); cmd.Parameters.AddWithValue("@SOHD", cthd.sohd); cmd.Parameters.AddWithValue("@MALOAIHD", cthd.maloaihd); cmd.Parameters.AddWithValue("@MANV", cthd.manv); cmd.Parameters.AddWithValue("@NGAYBATDAU", cthd.ngaybatdau); cmd.Parameters.AddWithValue("@NGAYKETTHUC", cthd.ngayketthuc); cmd.Parameters.AddWithValue("@LUONGCB", cthd.luongcb); int result = cmd.ExecuteNonQuery(); if (result == 1) { strMessage = cthd.sohd + " đã thêm thành công!"; } else { strMessage = cthd.sohd + " đã thêm không thành công!"; } conn.Close(); } return strMessage; }
public string Delete_CTHopDong(Cls_CTHopDong cthd) { string strMessage = string.Empty; using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); SqlCommand cmd = new SqlCommand("delete Tb_CTHopDong where SoHD=@SOHD", conn); cmd.Parameters.AddWithValue("@SOHD", cthd.sohd); int result = cmd.ExecuteNonQuery(); if (result == 1) { strMessage = cthd.sohd + " đã delete thành công!"; } else { strMessage = cthd.sohd + " delete không thành công!"; } conn.Close(); } return strMessage; }