//returns list with all characters from db public static List <Taxation> GetTaxations(MySqlConnection _connection) { _connection.Open(); //retrieve from db MySqlCommand command = _connection.CreateCommand(); command.CommandText = "SELECT * FROM `taxation`"; MySqlDataReader data = command.ExecuteReader(); List <Taxation> taxations = new List <Taxation>(); List <Enterprise> enterprises = EnterpriseDAO.GetEnterprises(_connection); //read data from dataReader and form list of Character instances while (data.Read()) { Int64 id = Convert.ToInt64(data["id"]); int taxation_group = Convert.ToInt32(data["taxation_group"]); decimal max_revenue = Convert.ToDecimal(data["max_revenue"]); int max_employee = Convert.ToInt32(data["max_employee"]); double VAT = Convert.ToDouble(data["VAT"]); double income_duty = Convert.ToDouble(data["income_duty"]); Taxation taxation = new Taxation(id, taxation_group, max_revenue, max_employee, VAT, income_duty); Debug.Log("Get taxation " + id); taxations.Add(taxation); } _connection.Close(); return(taxations); }
void EnterpriseTest(MySqlConnection connection) { List <Enterprise> enterprises = new List <Enterprise>(); enterprises.Add(new Enterprise(2, "MyEnterprise", 500.23M, 2.5, 4, 1)); EnterpriseDAO.InsertEnterprises(connection, enterprises); List <Enterprise> enterprises2 = EnterpriseDAO.GetEnterprises(connection); enterprises2[1].Title = "NewInterpise"; EnterpriseDAO.UpdateEnterprises(connection, enterprises2); enterprises2 = EnterpriseDAO.GetEnterprises(connection); EnterpriseDAO.DeleteEnterprises(connection, enterprises); enterprises2 = EnterpriseDAO.GetEnterprises(connection); }