コード例 #1
0
        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();
            }
        }
コード例 #2
0
        private void BtSave_Click(object sender, RoutedEventArgs e)
        {
            EncryptDecrypt encrypt = new EncryptDecrypt();

            _settings       = ClassSerializer.GetSettings();
            _settings.Type1 = encrypt.Encrypt(TextBoxHostName.Text);
            _settings.Type2 = encrypt.Encrypt(TextBoxPort.Text);
            _settings.Type3 = encrypt.Encrypt(TextBoxInitialCatalog.Text);
            _settings.Type4 = encrypt.Encrypt(TextBoxLogin.Text);
            _settings.Type5 = encrypt.Encrypt(TextBoxPassword.Password);


            //_settings.Type1 = hosneme;
            //_settings.Type1 = TextBoxHostName.Text;
            //_settings.Type2 = TextBoxPort.Text;
            //_settings.Type3 = TextBoxInitialCatalog.Text;
            //_settings.Type4 = TextBoxLogin.Text;
            //_settings.Type5 = TextBoxPassword.Password;
            _settings.Save();
            this.Close();
        }
コード例 #3
0
        public static ClassSerializer GetSettings()
        {
            ClassSerializer settings = null;


            if (File.Exists(filename))
            {
                using (FileStream fs = new FileStream(filename, FileMode.Open))
                {
                    XmlSerializer xser = new XmlSerializer(typeof(ClassSerializer));
                    settings = (ClassSerializer)xser.Deserialize(fs);
                    fs.Close();
                }
            }
            else
            {
                settings = new ClassSerializer();
            }

            return(settings);
        }