Exemplo n.º 1
0
 public override void OnWizardFinish(CancelEventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtFileToImport.Text))
         {
             throw new ApplicationException("请选择excel文件");
         }
         ExcelContext context = GetContext() as ExcelContext;
         context.ExcelFile     = txtFileToImport.Text;
         context.IncludeHeader = chkFirstRowColumnNames.Checked;
         DTSWizardBook wizardBook = GetWizard() as DTSWizardBook;
         if (wizardBook.Session.Direction == DTSDirection.Import)
         {
             Import(context);
         }
         else
         {
             Export(context);
         }
     }
     catch (Exception ex) {
         e.Cancel = true;
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            DTSWizardBook wizardBook = GetWizard() as DTSWizardBook;

            if (wizardBook.Session.Direction == DTSDirection.Import)
            {
                OpenFileDialog openFileDialogCSV = new OpenFileDialog();

                openFileDialogCSV.InitialDirectory = Application.ExecutablePath.ToString();
                openFileDialogCSV.Filter           = "excel文件|*.xls;*.xlsx";
                openFileDialogCSV.FilterIndex      = 1;
                openFileDialogCSV.RestoreDirectory = true;

                if (openFileDialogCSV.ShowDialog() == DialogResult.OK)
                {
                    this.txtFileToImport.Text = openFileDialogCSV.FileName.ToString();
                }
            }
            else
            {
                using (SaveFileDialog dialog = new SaveFileDialog())
                {
                    dialog.Filter           = "excel文件|*.xls;*.xlsx";
                    dialog.FilterIndex      = 2;
                    dialog.RestoreDirectory = false;

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        this.txtFileToImport.Text = dialog.FileName;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override void OnWizardFinish(System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtFileToImport.Text))
                {
                    throw new ApplicationException("请选择CSV文件");
                }

                DTSWizardBook wizardBook = GetWizard() as DTSWizardBook;
                if (wizardBook.Session.Direction == DTSDirection.Import)
                {
                    Import();
                }
                else
                {
                    Export();
                }
            }
            catch (Exception ex)
            {
                e.Cancel = true;
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
        public override void Prepare()
        {
            WizardContext context = null;

            if (csvRadioBtn.Checked)
            {
                context = new CsvContext();
            }
            else if (sqlserverRadioBtn.Checked)
            {
                context = new MsSqlContext();
            }
            else if (excelRadioBtn.Checked)
            {
                context = new ExcelContext();
            }
            context.InitailizeWizardPages();
            context.Pages.Insert(0, this);
            GetWizard().Context = context;
            DTSWizardBook wizardBook = GetWizard() as DTSWizardBook;

            context.Data = wizardBook.Session.DataSource;
        }