예제 #1
0
        private void ExcelExport()
        {
            string xlsFileName = Application.StartupPath + "\\" + Properties.Settings.Default.TEMPLATE_FILE_MASTER;

            if (!File.Exists(xlsFileName))
            {
                return;
            }

            DataTable exportTable = PrepareExportData();

            SaveFileDialog saveDialog_dlg = new SaveFileDialog();

            saveDialog_dlg.Filter = "Excel Files(*.xls) |*.xls";

            if (saveDialog_dlg.ShowDialog() == DialogResult.OK)
            {
                FileInfo fileInfo = new FileInfo(saveDialog_dlg.FileName);

                if (string.Equals(fileInfo.Name, Properties.Settings.Default.TEMPLATE_FILE_MASTER))
                {
                    return;
                }

                File.Copy(xlsFileName, saveDialog_dlg.FileName, true);

                ExportExcelProcess exportData = new ExportExcelProcess();

                exportData.ExportDataToExcel(saveDialog_dlg.FileName, exportTable, Properties.Settings.Default.EXCEL_SHEET_USER_MASTER);
            }
        }
예제 #2
0
        /// <summary>
        /// exports excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Export_btn_Click(object sender, EventArgs e)
        {
            //string xlsFileName = Application.StartupPath + "\\" + Properties.Settings.Default.EXPORT_TEMPLATE_FILE;

            //if (!System.IO.File.Exists(xlsFileName))
            //{
            //    return;
            //}

            SaveFileDialog ExcelExport_dlg = new SaveFileDialog();

            ExcelExport_dlg.FileName = string.Empty;
            ExcelExport_dlg.Filter   = "Excel Files(*.xls) |*.xls";

            if (ExcelExport_dlg.ShowDialog() == DialogResult.OK)
            {
                //System.IO.FileInfo fileInfo = new System.IO.FileInfo(ExcelExport_dlg.FileName);

                //if (string.Equals(fileInfo.Name, Properties.Settings.Default.EXPORT_TEMPLATE_FILE))
                //{
                //    return;
                //}

                //System.IO.File.Copy(xlsFileName, ExcelExport_dlg.FileName, true);
                //exportData.ExportDataToExcel(ExcelExport_dlg.FileName, BindDataForExcel(), Properties.Settings.Default.EXCEL_SHEET_USER_ROLE_AUTHORITY, true);
                this.Cursor = Cursors.WaitCursor;

                DataTable mesUserDt = getMesUser();

                DataTable userRoleAutyDt = BindDataForExcel();

                ExportExcelProcess exportData = new ExportExcelProcess();

                DataSet dsExport = new DataSet();

                if (mesUserDt != null && mesUserDt.Rows.Count > 0)
                {
                    mesUserDt.TableName = Properties.Settings.Default.EXCEL_SHEET_SAP_USER;

                    dsExport.Tables.Add(mesUserDt);
                }

                if (userRoleAutyDt != null && userRoleAutyDt.Rows.Count > 0)
                {
                    userRoleAutyDt.TableName = Properties.Settings.Default.EXCEL_SHEET_USER_ROLE_AUTHORITY;

                    dsExport.Tables.Add(userRoleAutyDt);
                }

                bool created = exportData.WriteToExcel(dsExport, ExcelExport_dlg.FileName);

                this.Cursor = Cursors.Default;
                if (created)
                {
                    MessageData messageData = new MessageData("mmci00012", Properties.Resources.mmci00012, null);
                    logger.Info(messageData);
                    popUpMessage.Information(messageData, Text);
                }
            }
        }
예제 #3
0
        private void DownloadExcel_btn_Click(object sender, EventArgs e)
        {
            //string templateFileName = Application.StartupPath + "\\" + Properties.Settings.Default.TEMPLATE_FILE_MASTER;
            string templateFileName = Application.StartupPath + "\\" + Properties.Settings.Default.TEMPLATE_FILE_LINE;

            if (!File.Exists(templateFileName))
            {
                messageData = new MessageData("mmci00011", Properties.Resources.mmci00011, Properties.Settings.Default.TEMPLATE_FILE_LINE);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);

                return;
            }

            SaveFileDialog saveDialog_dlg = new SaveFileDialog();

            saveDialog_dlg.Filter = "Excel Files(*.xls) |*.xls";

            if (saveDialog_dlg.ShowDialog() == DialogResult.OK)
            {
                //this.StartProgress(Properties.Resources.mmci00009);

                try
                {
                    File.Copy(templateFileName, saveDialog_dlg.FileName, true);
                    messageData = new MessageData("mmci00021", Properties.Resources.mmci00021, Properties.Settings.Default.TEMPLATE_FILE_LINE);
                    logger.Info(messageData);
                    popUpMessage.Information(messageData, Text);
                }
                catch (IOException copyError)
                {
                    this.CompleteProgress();
                    messageData = new MessageData("mmcc00001", Properties.Resources.mmcc00001, copyError.Message);
                    popUpMessage.ApplicationError(messageData, Text);
                    logger.Error(messageData);
                    return;
                }

                ExportExcelProcess excelProcess = new ExportExcelProcess();

                excelProcess.DownloadExcel(saveDialog_dlg.FileName, Properties.Settings.Default.EXCEL_SHEET_LINE_MASTER);

                this.CompleteProgress();
            }
        }
예제 #4
0
        /// <summary>
        /// Download Mold master excel template
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Download_btn_Click(object sender, EventArgs e)
        {
            string xlsFileName = Application.StartupPath + "\\" + Properties.Settings.Default.TEMPLATE_FILE_MASTER;

            if (!File.Exists(xlsFileName))
            {
                messageData = new MessageData("mmci00011", Properties.Resources.mmci00011, Properties.Settings.Default.TEMPLATE_FILE_MASTER);
                logger.Info(messageData);
                popUpMessage.Information(messageData, Text);
                return;
            }

            ExcelExport_sfdlg.FileName = string.Empty;
            ExcelExport_sfdlg.Filter   = "Excel Files(*.xls) |*.xls";

            if (ExcelExport_sfdlg.ShowDialog() == DialogResult.OK)
            {
                base.StartProgress(Properties.Resources.mmci00009);
                try
                {
                    File.Copy(xlsFileName, ExcelExport_sfdlg.FileName, true);
                }

                catch (IOException copyError)
                {
                    this.CompleteProgress();
                    messageData = new MessageData("mmcc00001", Properties.Resources.mmcc00001, copyError.Message);
                    popUpMessage.ApplicationError(messageData, Text);
                    logger.Error(messageData);
                    return;
                }

                ExportExcelProcess exportTemplate = new ExportExcelProcess();

                exportTemplate.DownloadExcel(ExcelExport_sfdlg.FileName, Properties.Settings.Default.EXCEL_SHEET_MOLD);

                this.CompleteProgress();
            }
        }