Пример #1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (Directory.Exists(txtExportPath.Text))
     {
         GlobalVariable.ExportPath   = txtExportPath.Text;
         GlobalVariable.IsConnection = false;
         GlobalMethod.CreateApp(GlobalVariable.ExportPath);
         MessageBox.Show("Export path saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     else
     {
         MessageBox.Show("Invalid path", "Output File Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #2
0
        private void btnConn_Click(object sender, EventArgs e)
        {
            if (txtServer.Text == null || txtServer.Text == "")
            {
                MessageBox.Show("Server name is empty", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (txtDatabase.Text == null || txtDatabase.Text == "")
            {
                MessageBox.Show("Database name is empty", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (txtUsername.Text == null || txtUsername.Text == "")
            {
                MessageBox.Show("Username is empty", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            //else if (txtPassword.Text == null || txtPassword.Text == "")
            //{
            //    //GlobalVariable.MySQLPassword = "";
            //    MessageBox.Show("Password is empty", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}
            else
            {
                GlobalVariable.MySQLServerName    = txtServer.Text;
                GlobalVariable.MySQLDatabaseName  = txtDatabase.Text;
                GlobalVariable.MySQLUsername      = txtUsername.Text;
                GlobalVariable.MySQLPassword      = txtPassword.Text;
                GlobalVariable.dbConnectionString = "SERVER=" + GlobalVariable.MySQLServerName + ";    " +
                                                    // "Port= " + txtport.Text + "; " +
                                                    "DATABASE=" + GlobalVariable.MySQLDatabaseName + "; " +
                                                    "UID=" + GlobalVariable.MySQLUsername + "; " +
                                                    "PWD=" + GlobalVariable.MySQLPassword + ";";

                GlobalVariable.MyADOConnection = new MySqlConnection(GlobalVariable.dbConnectionString);
                GlobalVariable.MyADOConnection.Open();
                if (GlobalVariable.MyADOConnection.State == ConnectionState.Open)
                {
                    GlobalMethod.CreateApp(GlobalVariable.dbConnectionString);
                    MessageBox.Show("Connected to Database : " + GlobalVariable.MySQLDatabaseName + "", "Connection Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CheckConn = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Please check your entry", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    CheckConn = false;
                }
            }
        }