示例#1
0
        bool loadDB()
        {
            try
            {
                var df = Properties.Settings.Default;
                MssBox.iWaitForm(splashScreenManager1);
                splashScreenManager1.SetWaitFormDescription(string.Format("Connecting {0}", df.Host));

                string conString = new System.Data.SqlClient.SqlConnectionStringBuilder()
                {
                    DataSource          = df.Host,
                    InitialCatalog      = df.DBName,
                    UserID              = df.Username,
                    Password            = OneSecurity.Decryption(df.Password),
                    PersistSecurityInfo = true,
                }.ConnectionString;

                using (var db = new CDMSDBDataContext(conString))
                {
                    db.Connection.Open();
                    splashScreenManager1.SetWaitFormDescription(string.Format("Connected {0}", df.Host));
                }
                Program.conStr = conString;
                MssBox.iWaitForm(splashScreenManager1);
                return(true);
            }
            catch (Exception ex)
            {
                MssBox.iWaitForm(splashScreenManager1);
                MssBox.Error(ex);
                return(false);
            }
        }
示例#2
0
 private void SettingForm_Load(object sender, EventArgs e)
 {
     txtHost.Text     = Properties.Settings.Default.Host;
     txtDatabase.Text = Properties.Settings.Default.DBName;
     txtUsername.Text = Properties.Settings.Default.Username;
     txtPassword.Text = OneSecurity.Decryption(Properties.Settings.Default.Password);
 }
示例#3
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                if (!dxValidationProvider1.Validate())
                {
                    return;
                }
                if (XtraMessageBox.Show("คุณต้องการเปลียนแปลง Server ใช้หรือไม่", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    MssBox.iWaitForm(splashScreenManager1);
                    #region ITSDB
                    var    df     = Properties.Settings.Default;
                    string HostDB = df.Host;
                    string DBName = df.DBName;
                    string User   = df.Username;
                    string Pass   = OneSecurity.Decryption(df.Password);

                    var ConStr = new System.Data.SqlClient.SqlConnectionStringBuilder()
                    {
                        DataSource          = txtHost.Text,
                        InitialCatalog      = txtDatabase.Text,
                        UserID              = txtUsername.Text,
                        Password            = txtPassword.Text,
                        PersistSecurityInfo = true,
                    }.ConnectionString;

                    if (!MessageConnect(ConStr))
                    {
                        MssBox.iWaitForm(splashScreenManager1);
                        return;
                    }

                    #endregion
                    df.Host     = txtHost.Text.Trim();
                    df.DBName   = txtDatabase.Text.Trim();
                    df.Username = txtUsername.Text.Trim();
                    df.Password = OneSecurity.Encryption(txtPassword.Text.Trim());
                    df.Save();
                    Program.conStr = ConStr;
                    MssBox.iWaitForm(splashScreenManager1);
                }
            }
            catch (Exception ex)
            {
                MssBox.iWaitForm(splashScreenManager1);
                MssBox.Error(ex);
            }
        }