private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) //Updates the Log with Response { while (client.Connected) { try { recieve = STR.ReadLine(); Regex matchComma = new Regex(","); String[] Results = matchComma.Split(recieve); int numOfResults = Int32.Parse(Results[0]); if (numOfResults == 0) { recieve = "There are no Data points with the given Search"; this.textBox2.Invoke(new MethodInvoker(delegate() { textBox2.AppendText("Server Responds: " + recieve + "\n"); })); } else { int numOfPoints = 5 * numOfResults; List <COVIDDataPoint> SearchResults = new List <COVIDDataPoint>(); for (int i = 1; i < numOfPoints; i += 5) { COVIDDataPoint point = new COVIDDataPoint(); point.ID = Int32.Parse(Results[i]); point.Date = Results[i + 1]; point.Country = Results[i + 2]; point.Sex = Results[i + 3]; point.Age = Results[i + 4]; SearchResults.Add(point); } Result = SearchResults; DispersePoints(); recieve = "There are " + numOfResults.ToString() + " Results for the specific Search"; this.textBox2.Invoke(new MethodInvoker(delegate() { textBox2.AppendText("Server Responds: " + recieve + "\n"); })); // PROBLEM: "country" is missing from most of the data in Result //DataTable.Close(); DataTable = new Form2(this, Result); Application.Run(DataTable); } recieve = ""; } catch (Exception x) { MessageBox.Show(x.Message.ToString()); } } }
private void button1_Click(object sender, EventArgs e) { int PointID = ++Parent.Parent.TotalPointNum; string Date = textBox2.Text; string Age = textBox1.Text; string Sex = comboBox2.Text; string Country = comboBox1.Text; if (dateCheck(Date)) { if (ageCheck(Age)) { string Ret = "New Data Point: " + Date + "," + Country + "," + Sex + "," + Age; Parent.CommunicateParent(Ret); Parent.addRow(PointID, Date, Country, Sex, Age); COVIDDataPoint newPoint = new COVIDDataPoint(); newPoint.ID = PointID; newPoint.Date = Date; newPoint.Country = Country; newPoint.Sex = Sex; newPoint.Age = Age; Parent.Parent.Result.Add(newPoint);; this.Close(); } else { MessageBox.Show("Invalid Age"); } } else { MessageBox.Show("Invalid Date"); } }