コード例 #1
0
        private void m_lnkExporter_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (!(m_dataGrid.DataSource is DataSet))
            {
                CFormAlerte.Afficher(I.T("This function cannot be used with this data set|30036"), EFormAlerteType.Erreur);
                return;
            }
            IExporteurDataset  exporteur   = null;
            IDestinationExport destination = null;

            if (CFormOptionsExport.EditeOptions(ref destination, ref exporteur))
            {
                if (exporteur != null)
                {
                    CResultAErreur result = exporteur.Export((DataSet)m_dataGrid.DataSource, destination);
                    if (!result)
                    {
                        CFormAlerte.Afficher(result);
                        return;
                    }
                    else
                    {
                        CFormAlerte.Afficher(I.T("Export finished|30037"));
                    }
                }
            }
        }
コード例 #2
0
        public static bool EditeOptions(ref IDestinationExport destination, ref IExporteurDataset exporteur)
        {
            CFormOptionsExport form = new CFormOptionsExport();
            bool bOk = form.ShowDialog() == DialogResult.OK;

            form.Exporteur = exporteur;
            if (bOk)
            {
                //destination = new CDestinationExportFile(form.m_panelOptions.FileName);
                destination = form.m_panelFormatExport.DestinationExport;
                exporteur   = form.Exporteur;
            }
            form.Dispose();
            return(bOk);
        }
コード例 #3
0
        private void m_lnkExport_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            IExporteurDataset  exporteur   = null;
            IDestinationExport destination = null;

            if (CFormOptionsExport.EditeOptions(ref destination, ref exporteur))
            {
                if (exporteur != null)
                {
                    DataSet   dsExport    = new DataSet();
                    DataTable tableExport = new DataTable("EXPORT");
                    foreach (DataGridViewColumn colView in m_grid.Columns)
                    {
                        if (!tableExport.Columns.Contains(colView.HeaderText))
                        {
                            tableExport.Columns.Add(colView.HeaderText);
                        }
                    }
                    int rowIndex = 0;
                    foreach (DataGridViewRow rowView in m_grid.Rows)
                    {
                        tableExport.Rows.Add(tableExport.NewRow());
                        foreach (DataGridViewColumn colView in m_grid.Columns)
                        {
                            int colIndex = colView.Index;
                            tableExport.Rows[rowIndex][colIndex] = rowView.Cells[colIndex].Value;
                        }
                        rowIndex++;
                    }

                    dsExport.Tables.Add(tableExport);
                    CResultAErreur result = exporteur.Export(dsExport, destination);
                    if (!result)
                    {
                        CFormAlerte.Afficher(result);
                        return;
                    }
                    else
                    {
                        CFormAlerte.Afficher(I.T("Export completed|30037"));
                    }
                }
            }
        }