zoukankan      html  css  js  c++  java
  • backgroundWorker用法

    private void btnQuery_Click(object sender, EventArgs e)
    {
    backgroundWorker1.RunWorkerAsync();
    btnQuery.Enabled = false;
    label8.Visible = true;
    }
    Thread myThread;
    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
    myThread = Thread.CurrentThread;
    DateTime dt1 = dateTimePicker1.Value;
    DateTime dt2 = dateTimePicker2.Value;
    string haocaiType = txtMaterialType.Text;
    string xitong = txtSystem.Text;
    string dep = txtDep.Text;
    string chejian = txtChejian.Text;
    string gongduan = txtReceptionGongDuan.Text;
    DataTable dt = lr.get_pr_proapplyheadMaterialSUM(dt1, dt2, haocaiType, xitong, dep, chejian, gongduan);
    backgroundWorker1.ReportProgress(100, dt);
    }

        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            try
            {
                DataTable dtPays = e.UserState as DataTable;
    
                Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();
                workbook.Open(Application.StartupPath + @"Templates耗材领用汇总表.xlt");
                Aspose.Cells.Worksheet sheet = workbook.Worksheets[0];//第一个工作表
    
                sheet.Cells.ImportDataTable(dtPays, false, "A3");
                sheet.Cells.DeleteRows(dtPays.Rows.Count, 5);
                fpSpread1.Sheets[0].OperationMode = FarPoint.Win.Spread.OperationMode.ReadOnly;
    
                MemoryStream ms = workbook.SaveToStream();
                ms.Seek(0, SeekOrigin.Begin);
                fpSpread1.OpenExcel(ms);
                ms.Close();
                fpSpread1.Sheets[0].RowCount = dtPays.Rows.Count + 4;
                fpSpread1.Sheets[0].ColumnCount = 6;
    
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            btnQuery.Enabled = true;
            label8.Visible = false;
        }
  • 相关阅读:
    1393 0和1相等串 鸽笼原理 || 化简dp公式
    C. Coin Troubles 有依赖的背包 + 完全背包变形
    D. PolandBall and Polygon BIT + 欧拉公式
    51NOD 1639 绑鞋带 数学
    D. Fedor and coupons 二分暴力
    hdu 4104 Discount
    bnu 51640 Training Plan DP
    hdu 5745 La Vie en rose DP + bitset优化
    hdu 5036 Explosion bitset优化floyd
    1354 选数字 DP背包 + 数学剪枝
  • 原文地址:https://www.cnblogs.com/VictorBlog/p/5478616.html
Copyright © 2011-2022 走看看