Esempio n. 1
0
        private void toolStripLabel2_Click_1(object sender, EventArgs e)
        {
            try
            {
                this.backgroundWorker1.RunWorkerAsync(); // 运行 backgroundWorker 组件
                DataTable dt = dataGridView1.DataSource as DataTable;
                if (dt == null)
                {
                    dt = new DataTable();
                    dt.Columns.Add("Id", typeof(int));
                    dt.Columns.Add("Name", typeof(String));
                    dt.Columns.Add("SeHao1", typeof(String));
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        if (dataGridView1.Rows[i].Cells[0].Value != null)
                        {
                            if (!dataGridView1.Rows[i].Cells[0].Value.Equals(string.Empty))
                            {
                                dt.Rows.Add(dataGridView1.Rows[i].Cells[2].Value, dataGridView1.Rows[i].Cells[1].Value, dataGridView1.Rows[i].Cells[0].Value);
                            }
                        }
                    }
                }
                cal.insertSehao(dt);
                JingDu form = new JingDu(this.backgroundWorker1, "提交中");// 显示进度条窗体
                form.ShowDialog(this);
                form.Close();


                MessageBox.Show("提交成功!");
                bindDatagridView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }