예제 #1
0
        private void btnSet_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you Sure update Server configuration?", "Veryfy", MessageBoxButtons.YesNo);

            /*Confirm user want yes or no*/
            if (dialogResult == DialogResult.Yes)
            {
                /*save server details into file*/
                string path = Application.StartupPath.ToString();

                ServerDetails serverDetails = new ServerDetailsFile();
                serverDetails.filePath = path + @"\dhanushka\databaseDetails.txt";
                serverDetails.Ip       = txtIp.Text.ToString();
                serverDetails.UserName = txtUserName.Text.ToString();
                serverDetails.password = txtPassword.Text.ToString();
                serverDetails.dataBase = txtDatabase.Text.ToString();

                if (serverDetails.Write() == true)
                {
                    MessageBox.Show("Compleate");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("File write erro");
                }
            }
        }
예제 #2
0
        public bool establish()
        {
            try {
                /*read file and get Server details*/
                string        path          = Application.StartupPath.ToString();
                ServerDetails serverDetails = new ServerDetailsFile();
                serverDetails.filePath = path + @"\dhanushka\databaseDetails.txt";
                serverDetails.Read();

                /*build Mysql connection*/
                MySqlConnectionStringBuilder connBuilder = new MySqlConnectionStringBuilder();

                connBuilder.Server   = "localhost";
                connBuilder.UserID   = serverDetails.UserName;
                connBuilder.Database = serverDetails.dataBase;
                connBuilder.Password = serverDetails.password;
                connBuilder.OldGuids = true;

                mysqlConnection = new MySqlConnection(connBuilder.ConnectionString);
                mysqlConnection.Open();

                isOpen = true;
            }
            catch (Exception e)
            {
                MainWindow.TaskBar = e.ToString();
                isOpen             = false;
            }
            return(isOpen);
        }