public List <Noninated_Contract> LoadNominatedContracts() { List <Noninated_Contract> OutList = new List <Noninated_Contract>(); string query = "SELECT * FROM BuyerToPlannerContracts;"; //Create a list to store the result List <string>[] list = new List <string> [2]; list[0] = new List <string>(); list[1] = new List <string>(); //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { list[0].Add(dataReader["NewContractID"] + ""); list[1].Add(dataReader["Customer_OrderID"] + ""); } //close Data Reader dataReader.Close(); List <Contract_for_Planner> inContracts = new List <Contract_for_Planner>(); for (int i = 0; i < list[0].Count; i++) { Contract_for_Planner current = new Contract_for_Planner(); current.New_ContractID = int.Parse(list[0][i]); current.Customer_orderID = int.Parse(list[1][i]); inContracts.Add(current); } //so all the contracts from the buyer are now in inContracts foreach (Contract_for_Planner x in inContracts) { Noninated_Contract temp = new Noninated_Contract(); temp.TheContract = LoadSingleContract(x.Customer_orderID); temp.New_ContractID = x.New_ContractID; OutList.Add(temp); } return(OutList); }
public void AddContractForPlanner(Noninated_Contract inContract) { //string query = " insert into BuyerToPlannerContacts(NewContactID, Customer_OrderID) values(" + // contractID + "," + // "\"" + x.client_Name + "\"," + // x.job_Type.ToString() + "," + // x.quantity.ToString() + "," + // "\"" + x.origin + "\"," + // "\"" + x.destination + "\"," + // x.van_Type.ToString() + ");"; //create command and assign the query and connection from the constructor // MySqlCommand cmd = new MySqlCommand(query, connection); //Execute command //cmd.ExecuteNonQuery(); }