예제 #1
0
        private void PrintDocumentPlants_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Bitmap bitmap = new Bitmap(this.PlantsTableView.Width, this.PlantsTableView.Height);

            PlantsTableView.DrawToBitmap(bitmap, new Rectangle(0, 0, this.PlantsTableView.Width, this.PlantsTableView.Height));
            e.Graphics.DrawImage(bitmap, 10, 10);
        }
예제 #2
0
        private void BackgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            DataTable        dt     = (DataTable)e.Argument;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                double onePercent = dt.Rows.Count / 100;
                int    counter    = i / ((int)Math.Ceiling(onePercent));

                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }
                else
                {
                    DataRow dr          = dt.Rows[i];
                    string  Genus       = Convert.ToString(dr[1]).Trim() == "" ? "?" : Convert.ToString(dr[1]).Trim();
                    string  Species     = Convert.ToString(dr[2]).Trim() == "" ? "sp." : Convert.ToString(dr[2]).Trim();
                    string  Subspecies  = Convert.ToString(dr[3]).Trim() == "" ? null : Convert.ToString(dr[3]).Trim();
                    string  FieldNumber = Convert.ToString(dr[4]).Trim() == "" ? null : Convert.ToString(dr[4]).Trim();
                    string  Habitat     = Convert.ToString(dr[5]).Trim() == "" ? null : Convert.ToString(dr[5]).Trim();
                    string  Synonym     = Convert.ToString(dr[6]).Trim() == "" ? null : Convert.ToString(dr[6]).Trim();
                    string  Source      = Convert.ToString(dr[7]).Trim() == "" ? "?" : Convert.ToString(dr[7]).Trim();
                    string  Replanted   = Convert.ToString(dr[8]).Trim() == "" ? null : Convert.ToString(dr[8]).Trim();
                    string  Notes       = Convert.ToString(dr[9]).Trim() == "" ? null : Convert.ToString(dr[9]).Trim();
                    string  Type        = Convert.ToString(dr[10]).Trim() == "" ? "?" : Convert.ToString(dr[10]).Trim();
                    int     ID          = Convert.ToInt32(Convert.ToString(dr[0]).Trim()) == 0 ? 0 : Convert.ToInt32(Convert.ToString(dr[0]).Trim());

                    this.plantsTableAdapter.InsertPlant(ID, Genus, Species, Subspecies, FieldNumber, Habitat, Synonym, Source, Replanted, Notes, Type);
                    SaveGenusToDb(Genus);

                    worker.ReportProgress(counter);
                }
            }
            PlantsTableView.Refresh();
        }