大家有没关于用户登陆的源代码啊?
那个"登陆"buttom的click事件里应该写些什么C#代码啊?
急求,谢谢谢谢!

解决方案 »

  1.   

    up bang yi xiawo meiyouxianchengde
      

  2.   

    <..onclick="登陆">
    public void denglu(object sender,Eventargs e)
    {
    ...
    }
      

  3.   

    if(usertext.Text.ToString().Trim()==""||passwordtext.Text.ToString().Trim()=="")
    {
    Response.Write("<script>alert('用戶名或密碼不能空')</script>");
    }

    int i;
    SqlConnection myconnect=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["myconnectionstring"]);
    //myconnect.ConnectionString="workstation id=HH_LI;packet size=4096;user id=sa; password=javabean ;data source=192.168.42.32;persist security info=False;initial catalog=bookmanage";
    SqlCommand mycommand=new SqlCommand();
    mycommand.Connection=myconnect; mycommand.CommandText="check_id2";
    mycommand.CommandType=CommandType.StoredProcedure;
    mycommand.Parameters.Add(new SqlParameter("@UserName",SqlDbType.VarChar,50));
    mycommand.Parameters.Add(new SqlParameter("@UserPassword",SqlDbType.VarChar,50));
    mycommand.Parameters.Add(new SqlParameter("@reason",SqlDbType.Int,4));
    mycommand.Parameters["@reason"].Direction=ParameterDirection.Output;
    // mycommand.Parameters["@resaon"].Value=0;
        
    mycommand.Parameters["@UserName"].Value=usertext.Text.Trim();
    mycommand.Parameters["@UserPassword"].Value=passwordtext.Text.Trim();
    try
    {
    mycommand.Connection.Open();
    mycommand.ExecuteNonQuery();
    i=Convert.ToInt32(mycommand.Parameters["@reason"].Value.ToString());
    if(i==1)
    {
    Response.Write("<script>window.open('frame.aspx','title','height=window.screen.availHeight,width=window.screen.availWidth,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no')</script>");
    }
    else
    {
    //Response.Redirect("login.aspx?a=1");
    Label3.Text="密碼或用戶名錯誤";
    }
    mycommand.Connection.Close();
    }
    catch(Exception ex)
    {
    Label3.Text=ex.ToString();
    }
    }
      

  4.   

    private void login()
    {
      string username,pwd;
      //check the username & pwd;
     //open another window}
      

  5.   

    //先写一个判断是不是通过的函数
    private bool chk(string userId,string Pwd)
    {
        //到数据库中查找有没有符合 userId,Pwd 的
        //如果有返回 true
        //没有返回  false
    }//电机确定按钮的时候
    if(chk())
    {
        Form fm = new From2();
        fm.show();
    }
    else
    {
        MessageBox.show("登陆失败");
    }