예제 #1
0
        protected void btn_Login_Click(object sender, EventArgs e)
        {
            string strSQL      = null;
            string strUsername = tb_UserName.Text.Trim();
            string strPassword = tb_Password.Text.Trim();

            if (strUsername != "" && strPassword != "")
            {
                strSQL = "SELECT [UserId],[PassWord] FROM [User] WHERE [UserId] = '" + strUsername + "' AND [PassWord] = '" + strPassword + "'";
                DataRow dr = SqlHelper.ExecuteDataRow(SqlLibrary.GetServer_Main(), CommandType.Text, strSQL);
                if (dr != null)
                {
                    strUsername = (string)dr["UserId"].ToString().Trim(); //插入的数据没有trim() 提醒王鑫
                    //Session["username"] = strUsername;
                    Response.Redirect("Show.aspx");
                }
                else
                {
                    Login_Info.Visible = true;
                    strMsg             = "<font color='red'>用户名或密码有误</font>";
                }
            }
            else
            {
                Login_Info.Visible = true;
                strMsg             = "<font color='red'>用户名或密码不能为空</font>";
            }
        }
예제 #2
0
        protected void btn_Register_Click(object sender, EventArgs e)
        {
            string strUsername = tb_UserName.Text.Trim();
            string strPassword = tb_Password.Text.Trim();

            string strSQL = "SELECT [UserId] FROM [User] WHERE [UserId] = '" + strUsername + "'";

            if (strUsername.Trim() != "" && strPassword.Trim() != "")
            {
                DataRow dr = SqlHelper.ExecuteDataRow(SqlLibrary.GetServer_Main(), CommandType.Text, strSQL);
                if (dr == null)
                {
                    strSQL = "INSERT INTO [User](UserId,PassWord,Mac) VALUES('" + strUsername + "','" + strPassword + "','111')";
                    SqlHelper.ExecuteNonQuery(SqlLibrary.GetServer_Main(), CommandType.Text, strSQL);
                    Register_Info.Visible = true;
                    strMsg = "<font color='red'>注册成功</font>";
                    Session["username"] = strUsername;
                    Response.Redirect("Show.aspx");
                }
                else
                {
                    Register_Info.Visible = true;
                    strMsg = "<font color='red'>用户名已被注册</font>";
                }
            }
            else
            {
                Register_Info.Visible = true;
                strMsg = "<font color='red'>用户名或密码不能为空</font>";
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Random rnd = new Random();

            ShowImg.Visible = false;
            //string strUserName = "******";
            ArrayList alBmp = new ArrayList();
            ArrayList alUid = new ArrayList();

            //Session["username"] = strUserName;
            //if (Session["username"] == null)
            //{
            //    Response.Redirect("Login.aspx");
            //}

            string        strSQL = "SELECT UserId,Bmp FROM [Media] ORDER BY Time DESC";
            SqlDataReader dr     = SqlHelper.ExecuteReader(SqlLibrary.GetServer_Main(), CommandType.Text, strSQL);

            if (dr != null)
            {
                int j = 0;
                sb.Append("<tr>");
                while (dr.Read())
                {
                    sb.Append("<td align=\"center\"><table><tr><td style='border-collapse:collapse;border: 1px solid #20B2AA;width:160px;height:160px;'><img src=\"./image/" + (string)dr["Bmp"].ToString().Trim() + "?tmp=" + rnd.Next(000000, 999999).ToString() + "\"/></td></tr><tr><td>" + (string)dr["UserId"].ToString().Trim() + "</td></tr></table></td>");
                    j++;
                    if (j == 3)
                    {
                        sb.Append("</tr>");
                        sb.Append("<tr>");
                        j = 0;
                    }
                }
                sb.Append("</tr>");
                dr.Close();
                ShowImg.Visible = true;
                strContent      = sb.ToString();
            }
            else
            {
                strContent = "当前没有在线用户~~~";
            }
        }