public void Execute() { NhomHangHoa.Domain.NhomHangHoa check = null; using (var cmd = new NhomHangHoaViewBusiness()) { cmd.NhomHanghoaId = item.NhomHanghoaId; check = cmd.Execute(); } if (check != null) { using (var cmd = new NhomHangHoaUpdateBusiness()) { cmd.item = item; cmd.Execute(); } } else { using (var cmd = new NhomHangHoaAddBusiness()) { cmd.item = item; cmd.Execute(); } } }
public NhomHangHoa.Domain.NhomHangHoa Execute() { NhomHangHoa.Domain.NhomHangHoa data = null; using (var conn = new SqlConnection(ConnectionString)) { using (var cmd = conn.CreateCommand()) { conn.Open(); cmd.CommandText = "SELECT * FROM NhomHangHoa WHERE NhomHanghoaId='" + NhomHanghoaId + "'"; using (var reader = cmd.ExecuteReader()) { if (reader.Read()) { data = new NhomHangHoa.Domain.NhomHangHoa(); data.NhomHanghoaId = Convert.ToString(reader["NhomHanghoaId"]); data.TenNhomHanghoa = Convert.ToString(reader["TenNhomHanghoa"]); data.GhiChu = Convert.ToString(reader["GhiChu"]); } } conn.Close(); } } return(data); }