예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtUid.Text == "k702760")
            {
                string          ee = string.Format("server={0};uid={1};pwd={2};database={3};", txtServer.Text, txtUid.Text, txtPassword.Text, txtDatabase.Text);
                LoginCred       tt = LoginCred.GetInstance();
                MySqlConnection dbConn;

                dbConn = new MySqlConnection(ee);
                try
                {
                    dbConn.Open();
                    tt.Creds = ee;
                    Hide();
                    Main form1 = new Main();
                    form1.Show();
                }
                catch (MySql.Data.MySqlClient.MySqlException)
                {
                    MessageBox.Show("False credentials", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("This is mapped (works) only for the user k702760", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #2
0
 public static LoginCred GetInstance()
 {
     if (_instance == null)
     {
         _instance = new LoginCred();
     }
     return(_instance);
 }