Esempio n. 1
0
        private async void btnDataView_Click(object sender, EventArgs e)
        {
            frmWaiting waiting = new frmWaiting();

            if (!Share.CheckOpened(waiting.Name))
            {
                waiting.Show();
                waiting.Focus();
                waiting.TopMost = true;
                waiting.Text    = "Excuting DataSearch...";
            }
            _iStartDate = int.Parse(sDate.Value.ToShortDateString().Replace("-", ""));
            _iEndDate   = int.Parse(eDate.Value.ToShortDateString().Replace("-", ""));

            btnDataView.Enabled = false;
            btnDataView.Text    = "EXcuting";

            DGVGrd.Visible = false;
            Task searchTask = Task.Run(() => SearchAsync());

            await searchTask;

            DGVGrd.Visible = true;
            DGVGrd.Refresh();
            btnDataView.Enabled = true;
            btnDataView.Text    = "Search";

            waiting.Close();
            waiting.Dispose();
            waiting = null;
        }
Esempio n. 2
0
        private async void btnExportExcel_Click(object sender, EventArgs e)
        {
            btnExportExcel.Enabled = false;
            btnExportExcel.Text    = "EXcuting";

            frmWaiting waiting = new frmWaiting();

            if (!Share.CheckOpened(waiting.Name))
            {
                waiting.Show();
                waiting.Focus();
                waiting.TopMost = true;
                waiting.Text    = "Exporting Excelfile...";
            }

            if (DGVGrd.RowCount > 1)
            {
                SaveFileDialog1.Filter           = "Excel Files|*.xlsx";
                SaveFileDialog1.InitialDirectory = MyApp.Path;
                if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string sTmpName;
                    sTmpName = SaveFileDialog1.FileName;

                    DGVGrd.SelectAll();  // DataGridView control
                    DataObject dataObj = DGVGrd.GetClipboardContent();
                    Clipboard.SetDataObject(dataObj, false);
                    DGVGrd.ClearSelection();

                    Task excelTask = Task.Run(() => ExportExcelAsync(sTmpName));

                    await excelTask;
                }
            }
            else
            {
                MessageBox.Show("데이터가 존재 하지 않습니다.", "엑셀저장 에러", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            btnExportExcel.Enabled = true;
            btnExportExcel.Text    = "Excel";

            waiting.Close();
            waiting.Dispose();
            waiting = null;
        }