Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Page.IsPostBack && Request.Form.Get("adminname") != "")
     {
         DAL.ExecuteSql exec = new DAL.ExecuteSql();
         string sqlText = "select * from scott.admin where name='" + Request["adminname"] + "' and password='******'";
         DataTable table = new DataTable();
         int flag = exec.run(table, sqlText);
         if (flag == 1)
         {
             if (table.Rows.Count > 0)
             {
                 Session["admin"] = Request["adminname"];
                 Response.Redirect("admin.aspx");
             }
             else
             {
                 Response.Write("<font size=10 color=red>用户名或密码不正确!</font>");
             }
         }
         else
         {
             Response.Write("<font size=10 color=red>" + exec.ErrorMessage + "</font>");
         }
     }
     else
     {
         Response.Write("<font size=10 color=red>请输入用户名</font>");
     }
 }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string name = Request["name"];
        if (name != null)
        {
            DAL.ExecuteSql exec = new DAL.ExecuteSql();
            DataTable table = new DataTable();
            string sqlText = "select * from scott.userinformation where name = '" + name + "'";
            exec.run(table, sqlText);
            Response.Clear();
            if (table.Rows.Count > 0)
            {
                //Response.Write("已经存在该用户名!");
                this.Response.Write("已经存在该用户名!");
                this.Response.End();
            }
            else
            {
                this.Response.Write("");
                this.Response.End();
            }

        }
        else
        {
            this.Response.Write("");
            this.Response.End();
        }
    }
Example #3
0
 private void WriteLog()
 {
     try
     {
         string strSql = "select max(id) from scott.ChatRoomLog";
         DAL.ExecuteSql exec = new DAL.ExecuteSql();
         DataTable table = new DataTable();
         exec.run(table, strSql);
         int id = -1;
         string str = table.Rows[0][0].ToString();
         if (table.Rows[0][0].ToString() == "")
         {
             id = 1;
         }
         else
         {
             id = Convert.ToInt32(table.Rows[0][0].ToString()) + 1;
         }
         strSql = "insert into scott.ChatRoomLog(id,name,message,chattime,ipaddress) values("
             + id + ","
             + "'" + Session["username"].ToString() + "',"
             + "'" + Request["sendMessage"] + "',"
             + "'" + System.DateTime.Now.ToString() + "',"
             + "'" + Request.UserHostAddress.ToString() + "'"
             + ")";
         int tmp = exec.run(strSql);
     }
     catch
     {
         Response.Write("error in writelog");
     }
 }
Example #4
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (this.TextBox1.Text.ToString() != "")
     {
         string sqlText = "update scott.userinformation set isallowmessage = '1' where name='" + this.TextBox1.Text.ToString() + "'";
         DAL.ExecuteSql exec = new DAL.ExecuteSql();
         int flag = exec.run(sqlText);
         if (flag == 1)
         {
             this.DropDownList2.SelectedValue = "可以";
         }
     }
 }
Example #5
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         string name = this.txt_name.Value.ToString();
         if (name != "")
         {
             DAL.ExecuteSql exec = new DAL.ExecuteSql();
             DataTable table = new DataTable();
             string sqlText = "select * from scott.userinformation where name = '";
             sqlText = sqlText + this.txt_name.Value.ToString() + "'";
             exec.run(table, sqlText);
             if (table.Rows.Count > 0)
             {
                 this.Response.Write("已经存在该用户名!");
             }
             else
             {
                 exec = new DAL.ExecuteSql();
                 sqlText = "insert into scott.userinformation values ("
                     + "'" + this.txt_name.Value.ToString() + "',"
                     + "'" + this.txt_password.Text.ToString() + "',"
                     + "'" + this.txt_email.Text.ToString() + "',"
                     + "'" + this.txt_realname.Text.ToString() + "',"
                     + "'" + this.txt_age.Text.ToString() + "',"
                     + "'" + this.txt_sex.Text.ToString() + "',"
                     + "'1', '1') ";
                 int flag = exec.run(sqlText);
                 if (flag == 1)
                 {
                     Session["username"] = this.txt_name.Value.ToString();
                     Application.Lock();
                     Application["message"] = Application["message"] + "welcom " + Session["username"] + "<br>";
                     Application.UnLock();
                     Response.Redirect("/chatRoom.html", false);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         string exception = ex.Message;
         string stack = ex.StackTrace;
     }
 }
Example #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     DataTable table = new DataTable();
     try
     {
         string strSql = "";
         strSql = "select isallowmessage from scott.userinformation where name='";
         strSql = strSql + Session["username"].ToString() + "'";
         DAL.ExecuteSql exec = new DAL.ExecuteSql();
         exec.run(table, strSql);
         if (table.Rows[0]["isallowmessage"].ToString() == "0")
         {
             Response.Write("禁止发言");
             return;
         }
     }
     catch (Exception ex)
     {
         string str = ex.Message;
         Response.Write("你还没有登录,请先<a href='default.aspx'>登录</a>");
         return;
     }
     try
     {
         //获取用户发送的信息
         string talk = Request["sendMessage"];
         //把当前用户发送的信息追加到以前用户所有用户发送的信息里面
         string message1 = Application["message"].ToString() + Session["username"].ToString() + " say:" + talk + "<br>";
         Application.Lock();
         //把信息存储在名为message的Application对象里面
         Application["message"] = message1;
         Application.UnLock();
         //把当前的用户发送信息的日志都存储在数据库中
         WriteLog();
     }
     catch (Exception ee)
     {
         string str = ee.Message;
         Response.Write("你还没有登录,请先<a href='chatmain.aspx'>登录</a>");
     }
 }
Example #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Page.IsPostBack && Request.Form.Get("username") != "")
     {
         DAL.ExecuteSql exec = new DAL.ExecuteSql();
         string sqlText = "select * from scott.userinformation where name='" + Request["username"] + "' and password='******'";
         DataTable table = new DataTable();
         int flag = exec.run(table, sqlText);
         if (flag == 1)
         {
             if (table.Rows.Count > 0)
             {
                 if (table.Rows[0]["isallowmessage"].ToString() == "1")
                 {
                     Session["username"] = Request["username"];
                     Application.Lock();
                     Application["message"] = Application["message"] + "welcom " + Session["username"] + "<br>";
                     Application.UnLock();
                     Response.Redirect("chatRoom.html");
                 }
                 else
                 {
                     Response.Write("<font size=10 color=red>该用户禁止发送信息</font>");
                 }
             }
             else
             {
                 Response.Write("<font size=10 color=red>用户名或密码不正确!请注册!</font>");
             }
         }
         else
         {
             Response.Write("<font size=10 color=red>" + exec.ErrorMessage + "</font>");
         }
     }
     else
     {
         Response.Write("<font size=10 color=red>请输入用户名</font>");
     }
 }
Example #8
0
 protected void Button3_Click(object sender, EventArgs e)
 {
     string sqlText = "";
     if (this.TextBox1.Text.ToString() == "")
     {
         sqlText = "select name,isonline,isallowmessage from scott.userinformation";
     }
     else
     {
         sqlText = "select name,isonline,isallowmessage from scott.userinformation where name='" + this.TextBox1.Text.ToString() + "'";
     }
     DAL.ExecuteSql exec = new DAL.ExecuteSql();
     DataTable table = new DataTable();
     int flag = exec.run(table, sqlText);
     if (flag == 1)
     {
         if (table.Rows.Count > 0)
         {
             this.GridView1.DataSource = table.DefaultView;
             this.GridView1.DataBind();
         }
     }
 }