Esempio n. 1
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            this.btnOK.Enabled     = false;
            this.btnCancel.Enabled = false;

            if (StaticWindows.Requester(
                    "Wollen Sie wirklich Ihre Microsoft SQL Server Datenbank in die SQLite Datenbank migrieren?"
                    ) == System.Windows.Forms.DialogResult.Yes)
            {
                this.lblState.Text = "Migration gestartet, lade Daten...";

                this.btnCancel.Enabled = true;

                this._importer = new SQLServerToSQLiteImporter();
                this._importer.PercentState += new ImportPercentEventHandler(_importer_PercentState);

                if (this._importer.Import())
                {
                    StaticWindows.InfoBox("Erfolgreich migriert!");
                }
                else
                {
                    StaticWindows.ErrorBox("Während der Migration ist ein Fehler aufgetreten!");
                }
            }
            else
            {
                this.lblState.Text = "Migration abgebrochen!";

                this.btnOK.Enabled     = true;
                this.btnCancel.Enabled = true;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the Click event of the btnOK control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.pbState.Value = 0;
            this.lblState.Text = "";

            this.lblState.Text = "Starte Export...";
            this.lblState.Refresh();
            this.lblState.Update();

            string filename   = "Movies_" + DateTime.Now.ToFileNameString() + ".xls";
            string targetPath = Configuration.CommonApplicationTempPath;
            string sheetTitle = "Filmliste vom " + DateTime.Now.ToShortDateString();

            if (!this.txtFilename.Text.IsNullOrTrimmedEmpty())
            {
                if (!PathExtensions.GetFullExtension(this.txtFilename.Text).ToLower().Contains(".xls") &&
                    !PathExtensions.GetFullExtension(this.txtFilename.Text).ToLower().Contains(".xlsx") &&
                    !PathExtensions.GetFullExtension(this.txtFilename.Text).ToLower().Contains(".ods"))
                {
                    this.txtFilename.Text = this.txtFilename.Text + ".xls";
                }

                filename = this.txtFilename.Text;
            }

            if (!this.txtTargetPath.Text.IsNullOrTrimmedEmpty())
            {
                bool thisTarget = false;

                if (!Directory.Exists(this.txtTargetPath.Text))
                {
                    if (StaticWindows.Requester(
                            "Das angegebene Verzeichnis existiert nicht, wollen sie es nun anlegen?"
                            ) == DialogResult.Yes)
                    {
                        try {
                            Directory.CreateDirectory(this.txtTargetPath.Text);

                            thisTarget = true;
                        }
                        catch (Exception ex) {
                            Exception ex2 = new Exception("Verzeichnis konnte nicht erstellt werden!", ex);

                            StaticWindows.DisplayErrorMessagebox(ex2);
                        }
                    }
                }

                if (thisTarget)
                {
                    targetPath = this.txtTargetPath.Text;
                }
            }

            if (!this.txtSheettitle.Text.IsNullOrTrimmedEmpty())
            {
                sheetTitle = this.txtSheettitle.Text;
            }

            this.btnOK.Enabled     = false;
            this.btnCancel.Enabled = false;

            this.txtFilename.Enabled   = false;
            this.txtTargetPath.Enabled = false;
            this.txtSheettitle.Enabled = false;

            this.cbExport.Enabled = false;

            this.groupBox1.Refresh();
            this.groupBox1.Update();

            foreach (CheckBox chk in this.colsPanel.Controls)
            {
                chk.Enabled = false;
            }

            this.groupBox2.Refresh();
            this.groupBox2.Update();

            this._Export(filename, targetPath, sheetTitle);
        }