private void DoDaFix() { // Enter your SQL code here // To run a T-SQL statement with no results, int RecordsAffected = _jurisUtility.ExecuteNonQueryCommand(0, SQL); // To get an ADODB.Recordset, ADODB.Recordset myRS = _jurisUtility.RecordsetFromSQL(SQL); //get all entryids into a list, count them and then send them one at a time to the time/expense processor current = 0; Errors = null; Errors1 = null; if (radioButtonT.Checked) { getTotalRecords(1); TimeProcessor tpThread = new TimeProcessor(_jurisUtility); backgroundWorkerTime.RunWorkerAsync(tpThread); } else if (radioButtonE.Checked) { getTotalRecords(2); ExpenseProcessor epThread = new ExpenseProcessor(_jurisUtility); backgroundWorkerExp.RunWorkerAsync(epThread); } else if (radioButtonTE.Checked) { getTotalRecords(3); BothProcessor bpThread = new BothProcessor(_jurisUtility); backgroundWorkerAll.RunWorkerAsync(bpThread); } else { MessageBox.Show("Please select an Entry Type before continuing", "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void backgroundWorkerExp_DoWork(object sender, DoWorkEventArgs e) { current = 0; eproc = e.Argument as ExpenseProcessor; BackgroundWorker worker = sender as BackgroundWorker; try { for (int a = 6; a < 10; a++) { eproc.processExpenseEntries(a.ToString()); backgroundWorkerExp.ReportProgress(current); var tlist = eproc.allExp.ToList(); foreach (ExpenseEntry tt in tlist) { current++; eproc.compareExpenseEntries(tt); backgroundWorkerExp.ReportProgress(current); } } } catch (Exception ex1) { e.Result = ex1; } if (eproc.correctedExpenses.Count == 0) { MessageBox.Show("There were no issues found in your expense entries," + "\r\n" + "so no changes are needed. The tool will now close"); Environment.ExitCode = 1; Application.Exit(); } else { DataTable dt = ConvertTo(eproc.correctedExpenses); Errors = new DataSet(); Errors.Tables.Add(dt); DialogResult tpr = seePreReport(); if (tpr == DialogResult.Yes) { ReportDisplay rpds = new ReportDisplay(null, Errors, 1); rpds.ShowDialog(); for (int d = 0; d < 10; d++) { var typeList = eproc.correctedExpenses.Where(c => c.newEntryStatus == d).ToList(); eproc.updateExpenseEntries(typeList, d); backgroundWorkerExp.ReportProgress(current); current++; } } else if (tpr == DialogResult.No) { for (int d = 0; d < 10; d++) { var typeList = eproc.correctedExpenses.Where(c => c.newEntryStatus == d).ToList(); eproc.updateExpenseEntries(typeList, d); backgroundWorkerExp.ReportProgress(current); current++; } } else if (tpr == DialogResult.Cancel) { Environment.ExitCode = 1; Application.Exit(); } } }