public Cls_KhuyenMai_DTA(Cls_KhuyenMai_DTA KMai_Data) { MaKM = KMai_Data.MaKM; TenKM = KMai_Data.TenKM; NoiDung = KMai_Data.NoiDung; GiaKM = KMai_Data.GiaKM; GiaHT = KMai_Data.GiaHT; NgayBD = KMai_Data.NgayBD; NgayKT = KMai_Data.NgayKT; TrangThai = KMai_Data.TrangThai; }
public void Insert_Update_Delete(Cls_KhuyenMai_DTA KM_Data,string sThucThi) { sConn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SP_KhuyenMai"; cmd.Connection = this.sConn; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MaKM", SqlDbType.Char); cmd.Parameters["@MaKH"].Value = KM_Data.MaKM; cmd.Parameters.Add("@TenKM", SqlDbType.NVarChar); cmd.Parameters["@TenKM"].Value = KM_Data.TenKM; cmd.Parameters.Add("@NoiDung", SqlDbType.NVarChar); cmd.Parameters["@NoiDung"].Value = KM_Data.NoiDung; cmd.Parameters.Add("@GiaKM", SqlDbType.Float); cmd.Parameters["@GiaKM"].Value = KM_Data.GiaKM; cmd.Parameters.Add("@GiaHT", SqlDbType.Float); cmd.Parameters["@GiaHT"].Value = KM_Data.GiaHT; cmd.Parameters.Add("@NgayBD", SqlDbType.DateTime); cmd.Parameters["@NgayBD"].Value = KM_Data.NgayBD; cmd.Parameters.Add("@NgayKT", SqlDbType.DateTime); cmd.Parameters["@NgayKT"].Value = KM_Data.NgayKT; cmd.Parameters.Add("@TrangThai", SqlDbType.Bit); cmd.Parameters["@TrangThai"].Value = KM_Data.TrangThai; cmd.Parameters.Add("@sqlTemp", SqlDbType.Char); if(sThucThi=="Insert"||sThucThi=="Update"||sThucThi=="Delete") cmd.Parameters["@sqlTemp"].Value = sThucThi; cmd.ExecuteNonQuery(); sConn.Close(); }