Exemplo n.º 1
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            Application.DoEvents();
            progressBar1.PerformStep();
            Application.DoEvents();
            DateTime     dtdenngay = dpkDenNgay.Value;
            nhacungcapBL ctrnhacc  = new nhacungcapBL();
            DataTable    dtnhacc   = new DataTable();

            try
            {
                Application.DoEvents();
                progressBar1.PerformStep();
                Application.DoEvents();
                dtnhacc = ctrnhacc.GetByPhieuNhap();
                Application.DoEvents();
                progressBar1.PerformStep();
                Application.DoEvents();
                if (dtnhacc != null)
                {
                    TKCongNoNhap ctr = new TKCongNoNhap();
                    string       kq  = "";
                    kq = ctr.Generate(txtpath.Text, dtdenngay, dtnhacc, progressBar1);
                    Application.DoEvents();
                    progressBar1.Value = progressBar1.Maximum;
                    Application.DoEvents();
                    if (kq.Trim().Equals("") == true)
                    {
                        MessageBox.Show("Tổng hợp dữ liệu thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Tổng hợp dữ liệu không thành công.\nChi tiết lỗi: " + kq, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    progressBar1.Value = 0;
                    Application.DoEvents();
                }
                else
                {
                    MessageBox.Show("Lỗi không tổng hợp được dữ liệu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    progressBar1.Value = 0;
                    Application.DoEvents();
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Lỗi không tổng hợp được dữ liệu.\nChi tiết lỗi: " + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                progressBar1.Value = 0;
                Application.DoEvents();
            }
        }