예제 #1
0
        private void BtVeryfy_Click(object sender, RoutedEventArgs e)
        {
            MyData connection = new MyData();

            connection.HostNameDb       = TextBoxHostName.Text;
            connection.PortDb           = TextBoxPort.Text;
            connection.InitialCatalogDb = TextBoxInitialCatalog.Text;
            connection.LoginDb          = TextBoxLogin.Text;
            connection.PasswordDb       = TextBoxPassword.Password;

            connection.myConnection();
            connection.connectionOpen();
            connection.connectionClose();

            if (connection.Error == "0")
            {
                StackPanelSetup.Visibility = Visibility.Hidden;
                BtVeryfy.Visibility        = Visibility.Hidden;
                BtSave.Visibility          = Visibility.Visible;
                BtSave.Focus();
            }


            /*
             * if (MyData.conn.State == ConnectionState.Open)
             *
             * {
             *  StackPanelSetup.Visibility = Visibility.Hidden;
             *  BtVeryfy.Visibility = Visibility.Hidden;
             *  BtSave.Visibility = Visibility.Visible;
             *  BtSave.Focus();
             *  //Lavender
             * }
             */
        }
        private void populate_combobox(string selectQuery, ComboBox comboBoxName, string column_name, string id)
        {
            //comboBoxName.Items.Clear(); // Clear combobox


            MyData myAdapter = new MyData();

            MySqlDataReader reader = myAdapter.MySqlDataReader(selectQuery);

            while (reader.Read())
            {
                comboBoxName.Items.Add(new { ColumnName = reader[column_name].ToString(), ColumnId = reader[id].ToString() });
            }

            myAdapter.connectionClose();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //FrTester(); // Delete this For normal loading
            // Screen sizeint --> theHeight = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            // Screen Size --> int theWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;

            /* ================== Size my App
             * var h = ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualHeight;
             * var w = ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualWidth;
             * this.Height = 300;
             * this.Width = 986;
             */

            MyData connection = new MyData();

            EncryptDecrypt encrypt = new EncryptDecrypt();

            _settings = ClassSerializer.GetSettings();

            if (_settings.Type1 != null & _settings.Type2 != null
                & _settings.Type3 != null & _settings.Type4 != null & _settings.Type5 != null)
            {
                connection.HostNameDb       = encrypt.Decrypt(_settings.Type1);
                connection.PortDb           = encrypt.Decrypt(_settings.Type2);
                connection.InitialCatalogDb = encrypt.Decrypt(_settings.Type3);
                connection.LoginDb          = encrypt.Decrypt(_settings.Type4);
                connection.PasswordDb       = encrypt.Decrypt(_settings.Type5);
            }
            connection.myConnection();
            connection.connectionOpen();
            connection.connectionClose();

            if (connection.Error == "0")
            {
                Open_FrAuthorization(MainWindow1, new RoutedEventArgs());
            }
            else
            {
                MessageBox.Show(connection.Error);
                FrErrorConnection frErrorConnection = new FrErrorConnection();
                frErrorConnection.Owner         = this;
                frErrorConnection.BtSave.Click += new RoutedEventHandler(Open_FrAuthorization);
                frErrorConnection.Show();
                //this.Show();
            }
        }