Exemple #1
0
        private void button_LogIn_Click(object sender, EventArgs e)
        {
            String UserName = textBox_UserName.Text;
            String Passwd   = textBox_Passwd.Text;

            if (UserName == Passwd)
            {
                Main_Menu main_menu = new Main_Menu();
                main_menu.Show();
                this.Hide();
            }
        }
        public int Login(String user, String password)
        {
            String load   = "select password from passwords where username='******' ";
            int    outint = 0;

            com.CommandText = load;

            try
            {
                cn.Open();
                dr = com.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        //System.Windows.Forms.MessageBox.Show(dr[0].ToString());
                        if (dr[0].ToString() == password)
                        {
                            Main_Menu mm = new Main_Menu();
                            mm.Show();
                            outint++;
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Invalid Password!!! please re- enter!!", "Password Error");
                        }



                        //listBox1.Items.Add(dr[0].ToString());
                        //listBox2.Items.Add(dr[1].ToString());
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Invalid Username & password combination please re-enter!!!", "Error");

                    //return false;
                }
                cn.Close();
            }
            catch (Exception)
            {
                throw;
            }
            return(outint);
        }
Exemple #3
0
        public int Login(String user, String password)
        {
            String load   = "select password,id from User_Password where user_name='" + user + "' ";
            int    outint = 0;

            user_name = user;
            //cmd = con.CreateCommand();

            try
            {
                con.Open();
                cmd             = con.CreateCommand();
                cmd.CommandText = load;
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        if (dr[0].ToString() == password)
                        {
                            user_id = dr[1].ToString();
                            Main_Menu mm = new Main_Menu();
                            mm.Show();
                            outint++;
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Invalid Password!!! please re- enter!!", "Password Error");
                        }
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Invalid Username & password combination please re-enter!!!", "Error");
                }
                con.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            return(outint);
        }