public deliverySevicesModel GetDeliverySevice(int ID) { deliverySevicesModel Dv = new deliverySevicesModel(); string connectionString = Configuration["ConnectionStrings:DefaultConnection"]; using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("LayDonViVanChuyen", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; if (connection.State == ConnectionState.Open) { connection.Close(); } command.Parameters.AddWithValue("@MaDv", ID); SqlDataAdapter da = new SqlDataAdapter(command); DataSet ds = new DataSet(); da.Fill(ds); Dv.MaDv = Convert.ToInt32(ds.Tables[0].Rows[0]["MaDvVanChuyen"]); Dv.TenDv = ds.Tables[0].Rows[0]["TenDv"].ToString(); Dv.GiaNoiThanh = Convert.ToDouble(ds.Tables[0].Rows[0]["GiaNoiThanh"]); Dv.GiaNgoaiThanh = Convert.ToDouble(ds.Tables[0].Rows[0]["GiaNgoaiThanh"]); } } return(Dv); }
public List <deliverySevicesModel> GetDeliverySevices() { List <deliverySevicesModel> DS = new List <deliverySevicesModel>(); string connectionString = Configuration["ConnectionStrings:DefaultConnection"]; using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("LayDsDonViVanChuyen", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; if (connection.State == ConnectionState.Open) { connection.Close(); } SqlDataAdapter da = new SqlDataAdapter(command); DataSet ds = new DataSet(); da.Fill(ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { deliverySevicesModel Dv = new deliverySevicesModel(); Dv.MaDv = Convert.ToInt32(ds.Tables[0].Rows[i]["MaDvVanChuyen"]); Dv.TenDv = ds.Tables[0].Rows[i]["TenDv"].ToString(); Dv.GiaNoiThanh = Convert.ToDouble(ds.Tables[0].Rows[i]["GiaNoiThanh"]); Dv.GiaNgoaiThanh = Convert.ToDouble(ds.Tables[0].Rows[i]["GiaNgoaiThanh"]); DS.Add(Dv); } } } return(DS); }