示例#1
0
        private void LoginForm_Load(object sender, EventArgs e)
        {
            try
            {
                String        version1 = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                SqlConnection SqlConn  = new SqlConnection(SqlLib.StrSqlConnection);
                if (SqlConn.State == ConnectionState.Closed)
                {
                    SqlConn.Open();
                }

                SqlCommand SqlComm = new SqlCommand();
                SqlComm.Connection = SqlConn;


                SqlComm.CommandText = @"SELECT * FROM " + FUVs.tableOfUsers;
                SqlDataAdapter oneAdapter = new SqlDataAdapter();
                oneAdapter.SelectCommand = SqlComm;

                oneAdapter.Fill(userInfoList);
                SqlComm.Dispose();
                oneAdapter.Dispose();

                if (SqlConn.State == ConnectionState.Open)
                {
                    SqlConn.Close();
                }
                SqlConn.Dispose();

                String    SSOnum  = Environment.UserName;
                DataRow[] dtUsers = userInfoList.Select("[SSO] = '" + SSOnum + "'");

                if (dtUsers.Length > 0)
                {
                    this.txtLoginName.Text = dtUsers[0]["LoginName"].ToString();
                    this.txtPassword.Text  = RijndaelAlgorithm.Decrypt(dtUsers[0]["Password"].ToString());
                }
                else
                {
                    this.txtLoginName.Text = "";
                }

                numberOfTry = 3;
            }
            catch (Exception)
            {
                labelTitle.Text  = "Please contact IT colleagues \n for database connection!";
                btnLogin.Enabled = false;
            }
        }
示例#2
0
        public void ReadConfigSettings()
        {
            string[] strLines = File.ReadAllLines(System.Windows.Forms.Application.StartupPath + "\\ConfigSettings.txt", System.Text.Encoding.Default);

            for (int i = 0; i < strLines.Length; i++)
            {
                strLines[i] = RijndaelAlgorithm.Decrypt(strLines[i]);
            }
            ;
            strSqlInfo = @"Data Source=" + strLines[0] +
                         ";Initial Catalog=" + strLines[1] +
                         ";Persist Security Info=True;User ID=" + strLines[2] +
                         ";Password="******";connect timeout=30;";
        }