示例#1
0
 private void btnImport_Click(object sender, EventArgs e)
 {
     if (int.TryParse(txtPeriod.Text, out pastelPeriod) && pastelPeriod >= 1 && pastelPeriod <= 12 && !String.IsNullOrEmpty(txtFileName.Text))
     {
         ReportWriter rw     = new ReportWriter();
         String       errors = "";
         List <Dictionary <String, String> > contents = rw.ExtractData(txtFileName.Text, out errors);
         lines = contents.Count;
         if (errors != "")
         {
             txtProgress.Text += errors + Environment.NewLine;
         }
         txtProgress.Text = "Starting processing" + Environment.NewLine;
         Application.DoEvents();
         txtProgress.Text += lines.ToString() + " in Excel file" + Environment.NewLine;
         MessageBox.Show("Extract Completed");
         Application.DoEvents();
         ProcessContents(contents);
         txtProgress.Text += processedLines.ToString() + " processed" + Environment.NewLine;
         Application.DoEvents();
         txtProgress.Text += "Completed" + Environment.NewLine;
         Application.DoEvents();
     }
     else if (!int.TryParse(txtPeriod.Text, out pastelPeriod) || pastelPeriod < 1 || pastelPeriod > 12)
     {
         MessageBox.Show("Please enter a valid period");
     }
     else
     {
         MessageBox.Show("Please select an Excel file!", "Imports");
     }
 }