public string Add_CTKiLuat(Cls_CTKiLuat ctkl) { string strMessage = string.Empty; using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); SqlCommand cmd = new SqlCommand("insert into Tb_CTKiLuat (MaCTKL,MaKL,MaNV,NgayKL,HinhThuc,NguyenNhan) values(@MACTKL,@MAKL,@MANV,@NGAYKL,@HINHTHUC,@NGUYENNHAN)", conn); cmd.Parameters.AddWithValue("@MACTKL", ctkl.mactkl); cmd.Parameters.AddWithValue("@MAKL", ctkl.makl); cmd.Parameters.AddWithValue("@MANV", ctkl.manv); cmd.Parameters.AddWithValue("@NGAYKL", ctkl.ngaykl); cmd.Parameters.AddWithValue("@HINHTHUC", ctkl.hinhthuc); cmd.Parameters.AddWithValue("@NGUYENNHAN", ctkl.nguyennhan); int result = cmd.ExecuteNonQuery(); if (result == 1) { strMessage = ctkl.mactkl + " đã thêm thành công!"; } else { strMessage = ctkl.mactkl + " đã thêm không thành công!"; } conn.Close(); } return strMessage; }
public string Delete_CTKiLuat(Cls_CTKiLuat ctkl) { string strMessage = string.Empty; using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); SqlCommand cmd = new SqlCommand("delete Tb_CTKiLuat where MaCTKL=@MACTKL", conn); cmd.Parameters.AddWithValue("@MACTKL", ctkl.mactkl); int result = cmd.ExecuteNonQuery(); if (result == 1) { strMessage = ctkl.mactkl + " đã delete thành công!"; } else { strMessage = ctkl.mactkl + " delete không thành công!"; } conn.Close(); } return strMessage; }
public string Update_CTKiLuat(Cls_CTKiLuat ctkl) { string strMessage = string.Empty; using (SqlConnection conn = new SqlConnection(strConnection)) { conn.Open(); SqlCommand cmd = new SqlCommand("update Tb_CTKiLuat set MaKL=@MAKL,MaNV=@MANV,NgayKL=@NGAYKL,HinhThuc=@HINHTHUC,NguyenNhan=@NGUYENNHAN where MaCTKL=@MACTKL", conn); cmd.Parameters.AddWithValue("@MACTKL", ctkl.mactkl); cmd.Parameters.AddWithValue("@MAKL", ctkl.makl); cmd.Parameters.AddWithValue("@MANV", ctkl.manv); cmd.Parameters.AddWithValue("@NGAYKL", ctkl.ngaykl); cmd.Parameters.AddWithValue("@HINHTHUC", ctkl.hinhthuc); cmd.Parameters.AddWithValue("@NGUYENNHAN", ctkl.nguyennhan); int result = cmd.ExecuteNonQuery(); if (result == 1) { strMessage = ctkl.mactkl + " đã update thành công!"; } else { strMessage = ctkl.mactkl + " update không thành công!"; } conn.Close(); } return strMessage; }