private void DynamicButton_Click(object sender, EventArgs e, Form passedForm) { string output = ""; StatMessage statMessage = new StatMessage(); statMessage.cpu_name = Environment.MachineName; foreach (Location mLoc in locations) { if (mLoc.loc_name.ToLower().Contains(cbLocation.GetItemText(cbLocation.SelectedItem).ToLower())) { statMessage.id_loc = mLoc.id; statMessage.location = cbLocation.GetItemText(cbLocation.SelectedItem).ToLower(); } } statMessage.year = cbInputYear.GetItemText(cbInputYear.SelectedItem); statMessage.month = cbInputMonth.GetItemText(cbInputMonth.SelectedItem).ToLower(); foreach (Control c in Controls) { if (c is TableLayoutPanel) { foreach (Control cIn in c.Controls) { if (cIn is TextBox) { bool upload = false; statMessage.stat_type = (String)cIn.Name; statMessage.stat_user = statUser; int countInt = 0; if (cIn.Tag.ToString().ToLower().Contains("string")) { if (!cIn.Text.Contains("Not Reported")) { statMessage.count = 0; statMessage.stat_comment = cIn.Text; upload = true; } } else { if (int.TryParse(cIn.Text, out countInt)) { statMessage.count = countInt; upload = true; } else { if (cIn.Text != "Not Reported") { MessageBox.Show($"Input for {statMessage.stat_type} is not a number and will not be uploaded"); } } } if (upload) { output += $"Stat: {statMessage.stat_type} Result: {apiStatWrapper.SetMonthlyStat(statMessage)}{Environment.NewLine}"; } } } } } MessageBox.Show(output); }
public string ApiSetMonthlyStat(StatMessage statMessage) => apiStatsWrapper.SetMonthlyStat(statMessage);