예제 #1
0
        private void m_buttonOK_Click(object sender, EventArgs e)
        {
            if (this.ValidateInput())
            {
                this.m_pictureLoading.Left = (this.Width - this.m_pictureLoading.Width) / 2;
                this.m_pictureLoading.Top  = (this.Height - this.m_pictureLoading.Height) / 2;

                this.tableLayoutPanel.Enabled = false;
                this.m_pictureLoading.Visible = true;
                this.m_pictureLoading.BringToFront();

                IDbCodeMembersProvider membersProvider = (IDbCodeMembersProvider)this.m_comboBoxMembersProvider.SelectedValue;
                new Thread(delegate() {
                    this.m_isGenerating = true;

                    try {
                        new DbCodeGenerator(new SqlServerCodeProvider(), membersProvider, CodeDomProvider.CreateProvider("CSharp")).GenerateCode(new DbDatabaseEntity(new DbSourceEntity(this.m_textDataSource.Text, new DbCredential(this.m_checkIsIntegratedSecurity.Checked, this.m_textUserID.Text, this.m_textPassword.Text), new SqlServerDatabaseEntityProvider()), this.m_textDatabase.Text, new SqlServerDataEntityProvider()), this.m_checkIsCascading.Checked, this.m_textEntityNamesapce.Text, this.m_textAccessorNamespace.Text, Path.Combine(Application.StartupPath, "GeneratedFiles"));
                        this.Invoke(new Action(delegate() {
                            PublicDialog.ShowMessage("Successfully!");
                        }));
                    } catch (Exception ex) {
                        this.Invoke(new Action(delegate() {
                            PublicDialog.ShowError(ex.Message);
                        }));
                    } finally {
                        this.Invoke(new Action(delegate() {
                            this.tableLayoutPanel.Enabled = true;
                            this.m_pictureLoading.Visible = false;
                        }));

                        this.m_isGenerating = false;
                    }
                }).Start();
            }
        }
예제 #2
0
        private bool ValidateInput()
        {
            if (string.IsNullOrWhiteSpace(this.m_textDataSource.Text))
            {
                PublicDialog.ShowWarning("Please input data source address.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(this.m_textDatabase.Text))
            {
                PublicDialog.ShowWarning("Please input database name.");
                return(false);
            }
            if (!this.m_checkIsIntegratedSecurity.Checked)
            {
                if (string.IsNullOrWhiteSpace(this.m_textUserID.Text))
                {
                    PublicDialog.ShowWarning("Please input user ID.");
                    return(false);
                }
            }
            if (string.IsNullOrWhiteSpace(this.m_textEntityNamesapce.Text))
            {
                PublicDialog.ShowWarning("Please input entity namespace.");
                return(false);
            }
            if (string.IsNullOrWhiteSpace(this.m_textAccessorNamespace.Text))
            {
                PublicDialog.ShowWarning("Please input accessor namespace.");
                return(false);
            }

            return(true);
        }