private void Load_Tax() { var items = new TaxCollection(); items.LoadItemsFromDb(); InputControls.LoadToComboBox(cboTax, items.Items); }
public static TaxCollection GetTaxRate() { TaxCollection taxes; //connect to database using (SqlConnection conn = new SqlConnection(connString)) { //query to retrieve data from Province table string query = @"SELECT TaxCode, TaxRate From TaxTable"; using (SqlCommand cmd = new SqlCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = query; cmd.Connection = conn; conn.Open(); taxes = new TaxCollection(); //read data using (SqlDataReader reader = cmd.ExecuteReader()) { string taxCode = null; decimal taxRate = 0.00m; while (reader.Read()) { taxCode = reader["TaxCode"] as string; taxRate = (decimal)reader["TaxRate"]; taxes.Add(new TaxRateTable { Taxcode = taxCode, TaxRate = taxRate }); } return(taxes); } } } }
//public TaxViewModel() //{ // // //} public TaxViewModel(TaxCollection taxes) { this.Taxes = taxes; }