Exemplo n.º 1
0
 public MainWindow()
 {
     InitializeComponent();
     GettingSettings.SettingValuesFromConfig();
     if (GettingSettings._sServer != null && GettingSettings._sServer != "")
     {
         try
         {
             string sqlConn = DatabaseProcedure.BuildingConnectionString();
             if (sqlConn != "")
             {
                 DatabaseProcedure.BuildingDatabase(sqlConn);
                 DatabaseProcedure.BuildingTable(sqlConn);
                 DatabaseProcedure.BuildingColumns(sqlConn);
             }
         }
         catch (Exception ex)
         { MessageBox.Show(ex.Message.ToString()); }
     }
     dgComponent.CanUserAddRows = false;
     dataGrid.CanUserAddRows    = false;
     dtShipDate.Text            = DateTime.Now.ToString();
     AddingItemsToDropDownList();
     AddingComponentsToGrid();
     FillingMainDataGrid(false);
     //StartingTimertoRefresh();
 }
Exemplo n.º 2
0
        public void SavingSettings()
        {
            Configuration config = GettingSettings.ConfigurationLocation();

            if (txtServer.Text != "")
            {
                config.AppSettings.Settings["Server"].Value = txtServer.Text.ToString();
            }
            if (txtDatabase.Text != "")
            {
                config.AppSettings.Settings["Database"].Value = txtDatabase.Text.ToString();
            }
            if (txtUsername.Text != "")
            {
                config.AppSettings.Settings["UserName"].Value = txtUsername.Text.ToString();
            }
            if (passwordBox.Password.ToString() != "")
            {
                var secure = new SecureString();
                foreach (char c in passwordBox.Password.ToString())
                {
                    secure.AppendChar(c);
                }
                config.AppSettings.Settings["Password"].Value = Password.EncryptString(secure);
            }

            config.Save();
        }
        public static string BuildingConnectionString()
        {
            string sqlConn = string.Empty;

            if ((GettingSettings._sServer != "" && GettingSettings._sServer != null) &&
                (GettingSettings._sDatabaseName != "" && GettingSettings._sDatabaseName != null) &&
                (GettingSettings._sUserName != "" && GettingSettings._sUserName != null) &&
                (GettingSettings._sPassword != null))
            {
                GettingSettings Settings = new GettingSettings();
                GettingSettings.SettingValuesFromConfig();
                string sDecryptedPword = Password.ToInsecureString(GettingSettings._sPassword);
                sqlConn = $"Server = {GettingSettings._sServer}; Database = {GettingSettings._sDatabaseName}; User Id = {GettingSettings._sUserName}; Password = {sDecryptedPword};";
            }
            return(sqlConn);
        }
Exemplo n.º 4
0
 public void FillingOutTxtBox()
 {
     GettingSettings.SettingValuesFromConfig();
     if (GettingSettings._sServer != "" && GettingSettings._sServer != null)
     {
         txtServer.Text = GettingSettings._sServer.ToString();
     }
     if (GettingSettings._sDatabaseName != "" && GettingSettings._sUserName != null)
     {
         txtDatabase.Text = GettingSettings._sDatabaseName.ToString();
     }
     if (GettingSettings._sUserName != "" && GettingSettings._sUserName != null)
     {
         txtUsername.Text = GettingSettings._sUserName.ToString();
     }
     if (GettingSettings._sPassword != null)
     {
         passwordBox.Password = Password.ToInsecureString(GettingSettings._sPassword);
     }
 }
Exemplo n.º 5
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     SavingSettings();
     GettingSettings.SettingValuesFromConfig();
     this.Close();
 }
Exemplo n.º 6
0
 public Window1()
 {
     InitializeComponent();
     GettingSettings.SettingValuesFromConfig();
     FillingOutTxtBox();
 }