Ejemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (i > 2)
            {
                MessageBox.Show("您已经密码错误了2次,不能登录");
                textBox1.Clear();
                textBox2.Clear();
                timer1.Enabled = true;
                btnOK.Enabled  = false;
                timer2.Enabled = true;
                return;
            }
            string yhm = textBox1.Text.ToString().Trim();
            string mm  = textBox2.Text.ToString().Trim();
            string yzm = textBox3.Text.ToString().Trim();

            dataValue.UserName = yhm;
            dataValue.Password = mm;
            string      sql2         = "select * from T_member where jobno='" + yhm + "' ";
            databaseexe databaseexe1 = new databaseexe();

            dataValue.StaffName = databaseexe1.getTopName(sql2);
            if (yhm == "")
            {
                MessageBox.Show("用户名不能为空!");
            }
            else
            {
                Connstr       connstr = new Connstr();
                SqlConnection conn    = connstr.getcon();
                string        sql     = "select * from T_user where username='******' and password='******' ";
                SqlCommand    cmd     = new SqlCommand(sql, conn);
                SqlDataReader dr      = cmd.ExecuteReader();
                if (dr.Read())
                {
                    MessageBox.Show("登陆成功");
                    databaseexe dbexe = new databaseexe();
                    string      sql1  = "select jobname from T_Member where jobNo='" + yhm + "'";
                    DataTable   de    =
                        dbexe.getdataset(sql1, "T_member").Tables[0];
                    for (int i = 0; i < de.Rows.Count; i++)
                    {
                        DataRow dc = de.Rows[i];
                        dataValue.StaffName = dc["jobname"].ToString();
                    }
                    FrmMain mainform = new FrmMain();
                    mainform.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!");
                    textBox1.Clear();
                    textBox2.Clear();
                    i++;
                }
            }
        }
Ejemplo n.º 2
0
        //执行sql
        public void sqlcmd(string sqlstr)
        {
            SqlConnection conn = connstr.getcon();
            SqlCommand    scmd = new SqlCommand(sqlstr, conn);

            scmd.ExecuteNonQuery();
            conn.Close();
        }