private void button1_Click(object sender, EventArgs e)
        {
            try
            {  
                if (textBox1.Text.Trim().Equals(string.Empty))
                {
                    MessageBox.Show("对不起用户名不能为空");
                }
                else
                {
                    if (textBox2.Text.Trim().Equals(string.Empty))
                    {
                        MessageBox.Show("对不起密码不能为空");
                    }
                    else
                    {
                        SqlConnection conn = new SqlConnection(@"Data Source=(local);Initial Catalog=工资信息管理系统;Integrated Security=True");                 //创建数据库连接
                        conn.Open();
                        SqlCommand cmd = null;
                        if (comboBox1.Text.Trim().Equals("--请选择--"))
                        {
                            MessageBox.Show("请选择身份");
                            comboBox1.Focus();
                            return;
                        }
                        switch (comboBox1.Text)
                        {
                            case "高级职员":
                                cmd = new SqlCommand("select count(*) from 职员—职员分类 where 用户名='" + textBox1.Text + "' and 用户密码='" + textBox2.Text + "' and 职工分类ID='001'", conn);
                                break;
                            case "中级职员":
                                cmd = new SqlCommand("select count(*) from 职员—职员分类 where 用户名='" + textBox1.Text + "' and 用户密码='" + textBox2.Text + "'and 职工分类ID='002'", conn);
                                break;
                            case "普通职员":
                                cmd = new SqlCommand("select count(*) from 职员—职员分类 where 用户名='" + textBox1.Text + "' and 用户密码='" + textBox2.Text + "'and 职工分类ID='003'", conn);
                                break;
                        }
                        int i = Convert.ToInt32(cmd.ExecuteScalar());           //获取返回值
                        if (i > 0)
                        {
                            if (comboBox1.Text == "高级职员")
                            {
                                Form2 f = new Form2();
                                f.Show();
                                this.Hide();
                            }
                        }
                        else
                        {
                            MessageBox.Show("对不起!你无权进入,请检查你用户名和密码或登录界面选择是否正确!");          //弹出提示
                        }
                    }
                  }            }
            catch (Exception ex)
            {
                ex.GetType();
            }        }
请解释下 谢谢!!

解决方案 »

  1.   

    你在开头打个断点,debug一下,不就找得出为什么没反应了。。
      

  2.   


    textBox1.Text.Trim().Equals(string.Empty);
    //Equals全部换成
    textBox1.Text.Trim() == string.Empty;
      

  3.   

    你在try前加一行:
    MessageBox.Show("有反应没?");
    就知道该button有没有反应了.
      

  4.   

    还一个原因就是误操作
    导致这个按钮的Click事件没关联button1_Click这个事件,点击无效。
      

  5.   

    设断点调试下,看看有没有进入button1_Click
      

  6.   

    按钮的  click 事件绑定没
      

  7.   

    看你的button是在那起作用的  然后敲个断点  问题就出来了 相信你会解决的
      

  8.   


    <asp:Button ID="Button3" runat="server" Text="Excel导出" OnClick="ExcelOut" OnClientClick="clint();"  class="normal-button" />看看如果你有加OnClientClick事件 js有没有return true,如果false那就不会进入OnClick事件了
      

  9.   

    你在你的Button点击事件里加个Message.Show("aaa");在试试,就能知道该Button有没有反应了~~!!