/* protected void discuss_Click(object sender, EventArgs e) * { * discuss.PostBackUrl= "~/discuss.aspx? ID ='"+Request["ID"]+"'"; * }*/ protected void btnok_Click(object sender, EventArgs e) { MySqlData da = new MySqlData(); string cmdtxt = "insert into tb_reply(Uname,Content,ReplyTime,ReplyID)"; cmdtxt += "values('" + Session["userName"].ToString() + "','" + txtReply.Text + "','" + DateTime.Now + "','" + Request["subjectID"].ToString() + "')"; if (da.ExceSQL(cmdtxt)) { Response.Write("<script>alert('回复成功');location='ShowWords.aspx?subjectID=" + Request["subjectID"] + "'</script>"); txtReply.Text = ""; } else { Response.Write("<script>alert('回复失败')</script>"); } }
protected void btnOK_Click(object sender, EventArgs e) { MySqlData da = new MySqlData(); string cmdtxt = "insert into tb_leaveword(Uid,Subject,Content,leaveTime)"; cmdtxt += "values('" + Session["userName"].ToString() + "','" + txtSubject.Text + "','" + txtContent.Text + "','" + DateTime.Now + "')"; bool add = da.ExceSQL(cmdtxt); if (add == true) { Response.Redirect("ShowSubject.aspx"); } else { Response.Write("<script>alert('发送失败!')"); } }
protected void Logon_Click(object sender, EventArgs e) { if ((txtUserName.Text == "" || txtPassword.Text == "" || txtQpassword.Text == "" || txtQQ.Text == "") || (male.Checked == false && famale.Checked == false) || txtPassword.Text != txtQpassword.Text) { Response.Write("<script>alert('注册失败,请正确填写信息!')</script>"); } else { if (isName()) { Response.Write("<script>alert('注册失败,该用户名已被注册!')</script>"); } else { string userName = txtUserName.Text; MD5Class md5 = new MD5Class(); string userPass = md5.Md5Encrypt(txtPassword.Text); string qq = txtQQ.Text; string sex = ""; if (male.Checked == true) { sex = "male"; } else if (famale.Checked == true) { sex = "famale"; } string mysqlinsert = "insert into tb_user(Uid,PassWord,QQ,Sex) values('" + userName + "','" + userPass + "','" + qq + "','" + sex + "')"; MySqlData da = new MySqlData(); bool add = da.ExceSQL(mysqlinsert); if (add == true) { Response.Write("<script>alert('注册成功!')</script>"); txtPassword.Text = txtQpassword.Text = txtUserName.Text = txtQQ.Text = ""; } else { Response.Write("<script>alert('注册失败!')</script>"); } } } }
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { switch (e.CommandName) { case "first": pds.CurrentPageIndex = 0; BindDataList1(pds.CurrentPageIndex); break; case "pre": pds.CurrentPageIndex = pds.CurrentPageIndex - 1; BindDataList1(pds.CurrentPageIndex); break; case "next": pds.CurrentPageIndex = pds.CurrentPageIndex + 1; BindDataList1(pds.CurrentPageIndex); break; case "last": pds.CurrentPageIndex = pds.PageCount - 1; BindDataList1(pds.CurrentPageIndex); break; case "btnok": if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { MySqlData da = new MySqlData(); Label mainID = e.Item.FindControl("mainID") as Label; TextBox txtreply = e.Item.FindControl("txtReply") as TextBox; mainID.Visible = true; string cmdtxt = "insert into tb_reply(Uname,Content,ReplyTime,ReplyID)"; cmdtxt += "values('" + Session["userName"].ToString() + "','" + txtreply.Text + "','" + DateTime.Now + "','" + Convert.ToInt32(mainID.Text) + "')"; if (da.ExceSQL(cmdtxt)) { txtreply.Text = ""; BindDataList1(pds.CurrentPageIndex); } else { Response.Write("<script>alert('回复失败')</script>"); } } break; case "search": if (e.Item.ItemType == ListItemType.Footer) { int PageCount = int.Parse(pds.PageCount.ToString()); TextBox txtPage = e.Item.FindControl("txtPage") as TextBox; int MyPageNum = 0; if (!txtPage.Text.Equals("")) { MyPageNum = Convert.ToInt32(txtPage.Text.ToString()); } if (MyPageNum <= 0 || MyPageNum > PageCount) { Response.Write("<script>alert('请输入页数并确定没有超出总页数!')</script>"); } else { BindDataList1(MyPageNum - 1); } } break; } }