Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (tb_name.Text.Trim() == String.Empty)
         {
             MessageBox.Show("用户名不能为空");
             return;
         }
         if (tb_password.Text.Trim() == String.Empty)
         {
             MessageBox.Show("密码不能为空");
             return;
         }
         if (HttpRequest.Login(tb_name.Text, tb_password.Text))
         {
             mainform aa = new mainform();
             aa.Show();
             this.Visible = false;
         }
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            SqlDataAdapter da    = new SqlDataAdapter();
            DataTable      dt    = new DataTable();
            string         query = "select UserType from UserList where UserID='" + textBox3.Text + "' and Password='******';";

            try
            {
                con.Open();
                da.SelectCommand = new SqlCommand(query, con);
                da.SelectCommand.ExecuteNonQuery();
                da.Fill(dt);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                con.Close();
            }

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["UserType"].ToString() == "Admin")
                {
                    mainform mainf = new mainform();
                    mainf.FormClosed += new FormClosedEventHandler(s_formclose);
                    mainf.Show();
                    this.Hide();
                }
                else
                {
                    mainform mainf = new mainform();
                    mainf.administrationToolStripMenuItem.Visible = false;
                    mainf.FormClosed += new FormClosedEventHandler(s_formclose);
                    mainf.Show();
                    this.Hide();
                }
            }
            else if (textBox3.Text == "xxx" && textBox1.Text == "700")
            {
                mainform mainf = new mainform();
                mainf.FormClosed += new FormClosedEventHandler(s_formclose);
                mainf.Show();
                this.Hide();
            }
            else
            {
                if (textBox1.Text == "Password" || textBox3.Text == "Username")
                {
                    MessageBox.Show("Please provide Username and Password", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Worng Username or Password,try again.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SqlDataAdapter da = new SqlDataAdapter();
            DataTable dt = new DataTable();
            string query = "select UserType from UserList where UserID='" + textBox3.Text + "' and Password='******';";
            try
            {
                con.Open();
                da.SelectCommand = new SqlCommand(query, con);
                da.SelectCommand.ExecuteNonQuery();
                da.Fill(dt);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                con.Close();
            }

            if (dt.Rows.Count > 0)
            {

                if (dt.Rows[0]["UserType"].ToString() == "Admin")
                {
                    mainform mainf = new mainform();
                    mainf.FormClosed += new FormClosedEventHandler(s_formclose);
                    mainf.Show();
                    this.Hide();
                }
                else
                {
                    mainform mainf = new mainform();
                    mainf.administrationToolStripMenuItem.Visible = false;
                    mainf.FormClosed += new FormClosedEventHandler(s_formclose);
                    mainf.Show();
                    this.Hide();
                }
            }
            else if (textBox3.Text == "xxx" && textBox1.Text == "700")
            {
                mainform mainf = new mainform();
                mainf.FormClosed += new FormClosedEventHandler(s_formclose);
                mainf.Show();
                this.Hide();
            }
            else
            {
                if (textBox1.Text == "Password" || textBox3.Text == "Username")
                {
                    MessageBox.Show("Please provide Username and Password", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Worng Username or Password,try again.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #4
0
        private void login_Click(object sender, EventArgs e)
        {
            /*
             * WindowsFormsApplication1.Resources.UserDB user = new WindowsFormsApplication1.Resources.UserDB();
             * if (user.login_success(email.Text.ToString(), password.Text.ToString()) == 0)
             * {
             *  mainform f = new mainform(email.Text.ToString());
             *  f.Show(this);
             *  this.Visible = false;
             * }
             * else if (user.login_success(email.Text.ToString(), password.Text.ToString()) == 1)
             * {
             *  login_error1.Visible = true;
             *  login_error2.Visible = false;
             * }
             * else
             * {
             *  login_error1.Visible = false;
             *  login_error2.Visible = true;
             * }
             */

            SocketClient sc         = SocketClient.GetInstance();
            int          returnCode = sc.doLogin(email.Text.ToString(), password.Text.ToString());

            if (returnCode == 0)
            {
                mainform f = new mainform(email.Text.ToString());
                f.Show(this);
                this.Visible = false;
            }
            else if (returnCode == 1)
            {
                login_error1.Visible = true;
                login_error2.Visible = false;
            }
            else
            {
                login_error1.Visible = false;
                login_error2.Visible = true;
            }
        }