Exemple #1
0
        private void iok_Click(object sender, EventArgs e)
        {
            管理员主界面 frma      = new 管理员主界面(this);
            User   user      = new User();
            MyDB   sqlHelper = new MyDB();
            string sql1      = "select * from user where name=@name ";
            string sql2      = "select * from user where name=@name and  password=@password ";
            Dictionary <string, Object> dic = new Dictionary <string, Object>();

            dic.Add("@name", texta.Text);
            dic.Add("@password", textb.Text);
            ArrayList al = new ArrayList();

            al = sqlHelper.SelectInfo(sql1, dic);
            if (al != null && al.Count > 0)//判断是否有用户名
            {
                al = sqlHelper.SelectInfo(sql2, dic);
                if (al != null && al.Count > 0)
                {
                    foreach (Object[] obj in al)
                    {   //得到几行数据就能产生多少个对象
                        user.setId((int)obj[0]);
                        //强转成你需要的数据,强转很容易发生异常,所以数据库的约束性要强,对象类时要认真检查数据类型,多用try...catch
                        user.setName((string)obj[1]);
                        user.setPassword((string)obj[2]);
                    }
                    frma.ControlBox = false;//设置窗体
                    frma.setUser(user);
                    frma.Show();
                    this.Hide();
                }
                else
                {
                    label2.Text = "密码错误";
                }
            }
            else
            {
                label2.Text = "请检查用户名";
                MessageBox.Show("如果是员工请点击查询!", "帮助");
            }
        }
Exemple #2
0
 public void setGzandGl(工资管理 gz, 管理员主界面 gl)
 {
     this.gz = gz;
     this.gl = gl;
 }
Exemple #3
0
 public void setGuanli(管理员主界面 gl)
 {
     this.gl = gl;
 }
Exemple #4
0
 public void setUseandGuanli(User user, 管理员主界面 guanli)
 {
     this.user   = user;
     this.guanli = guanli;
 }
Exemple #5
0
 public void getGl(管理员主界面 gl)
 {
     this.gl = gl;
 }