예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("Select * from adminlogin where username=@username AND password=@password", con);

            cmd.Parameters.AddWithValue("@username", username.Text);
            cmd.Parameters.AddWithValue("@password", password.Text);
            SqlDataAdapter adapt = new SqlDataAdapter(cmd);
            DataSet        ds    = new DataSet();

            adapt.Fill(ds);
            con.Close();
            int    count = ds.Tables[0].Rows.Count;
            string str;

            str = "select * from adminlogin";
            SqlCommand com = new SqlCommand(str, con);

            con.Open();
            SqlDataReader reader = com.ExecuteReader();

            if (string.IsNullOrEmpty(username.Text) && string.IsNullOrEmpty(password.Text))
            {
                labelMessage.ForeColor = Color.Red;
                labelMessage.Text      = "Please fill the required fields!";
                username.Focus();
            }
            else if (string.IsNullOrEmpty(username.Text))
            {
                labelMessage.ForeColor = Color.Red;
                labelMessage.Text      = "Please fill the username field!";
                username.Focus();
            }
            else if (string.IsNullOrEmpty(password.Text))
            {
                labelMessage.ForeColor = Color.Red;
                labelMessage.Text      = "Please fill the password field!";
                password.Focus();
            }

            else if (count == 1)
            {
                getTheName(username.Text);
                MessageBox.Show("Welcome, " + UppercaseFirst(adminusername) + "!");
                Hide();
                aselco201users fm = new aselco201users();
                fm.Show();
            }
            else
            {
                labelMessage.ForeColor = Color.Red;
                labelMessage.Text      = "Invalid username or password!";

                password.Text = "";
                password.Focus();
            }
            con.Close();
        }
예제 #2
0
        public static bool CloseCancel()
        {
            const string message = "Are you sure that you would like to close?";
            const string caption = "Closing ASELCO 201 File System";
            var          result  = MessageBox.Show(message, caption,
                                                   MessageBoxButtons.YesNo,
                                                   MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                LoginForm      login      = new LoginForm();
                aselco201users adminlogin = new aselco201users();
                login.Close();
                adminlogin.Close();

                Environment.Exit(0);

                return(true);
            }
            else
            {
                return(false);
            }
        }