winfrom的登录 
string compcode = string.Empty;
            string name = string.Empty;
            string code = string.Empty;
            string psd = string.Empty;
            //string psd = string.Empty;
            if (this.txtUserName.Text == string.Empty)
            {
                MessageBox.Show("用户名不能为空!");
                this.txtUserName.Focus();
                return;
            }
            if (this.txtPassWord.Text == string.Empty)
            {
                MessageBox.Show("请输入密码!");
            }
            else if (UserManage.Userinfo_name.Contains(this.txtUserName.Text) || UserManage.Userinfo_code.Contains(this.txtUserName.Text))
            {
                // string psd = string.Empty;
                if (this.txtcompcode .Text ==compcode ||this.txtPassWord.Text == psd ||this.txtUserName.Text ==name||this.txtUserName .Text ==code)
                {
                    MessageBox.Show("欢迎登录本系统!", "登录成功!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("密码错误,请重新输入!", "密码错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.txtPassWord.Text = string.Empty;
                    this.txtPassWord.Focus();
                }
            }
            else
            {
                 MessageBox.Show("用户名不存在!", "登录失败!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                  this.txtUserName.Text = string.Empty;
                  this.txtPassWord.Text = string.Empty;
                  this.txtUserName.Focus();  
                //this.DialogResult = DialogResult.OK;              
            }
            DataTable dt = HL_UserinfoBLLGen.GetdtList(compcode ,name ,code , psd);  

解决方案 »

  1.   

    if (this.txtcompcode .Text ==compcode ||this.txtPassWord.Text == psd ||this.txtUserName.Text ==name||this.txtUserName .Text ==code)
    你这句是啥意思,得到的好像都是空吧!你可以断点调试一下!
      

  2.   

    没有做过winform程序。。可能是代码写错位置了吧,起码应该是点击登录后再判断是否成功啊,怎么一运行程序就提示登录是否成功呢??自己先调试一下吧!!
      

  3.   

                  在一个DAL层里面有做数据的查询。
      

  4.   

    UserManage.Userinfo_name.Contains(this.txtUserName.Text) || UserManage.Userinfo_code.Contains(this.txtUserName.Text)
    重点看这里,看看是否有相关的登录值.
      

  5.   

     if (this.txtcompcode .Text ==compcode ||this.txtPassWord.Text == psd ||this.txtUserName.Text ==name||this.txtUserName .Text ==code)这话只是为TextBox赋值吧、应该判断和数据库中字段的匹配、
    如: if(DateSet.Tables[0].Rows[0]["name"].ToString() == name )