예제 #1
0
        private void bntOK_Click(object sender, EventArgs e)
        {
            if (txtUser.Text == "")
            {
                MessageBox.Show("用户名不能为空!", "提示");
                txtUser.Focus();
                return;
            }
            if (txtPassword.Text == "")
            {
                MessageBox.Show("密码不能为空!", "提示");
                txtPassword.Focus();
                return;
            }
            Userclass tbClass = new Userclass();

            tbClass.strUserEng = txtUser.Text;
            tbClass.strPasword = txtPassword.Text;
            if (tbClass.tbUserLogIn(tbClass) == 1)
            {
                FormMain frman = new FormMain();
                frman.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("登录失败!", "提示");
                txtPassword.Text = "";
                txtUser.Text     = "";
            }
        }
예제 #2
0
        public int tbUserLogIn(Userclass Customer)
        {
            DataBase tbuser  = new DataBase();
            int      intFalg = 0;

            try
            {
                //MySqlConnection sqlcon = addnc.getcon();
                string          select = "select * from tbUser where username='******' and password='******'";
                MySqlDataReader reader = null;
                tbuser.getcon();
                MySqlCommand cmd = new MySqlCommand(select, tbuser.My_Conn);
                reader = cmd.ExecuteReader();
                reader.Read();
                if (reader.HasRows)
                {
                    intFalg = 1;
                }
                return(intFalg);
            }
            catch (Exception ee)
            {
                return(intFalg);
            }
        }