protected void LoginBtn_Click(object sender, EventArgs e) { Logic.Login mlogin = new Logic.Login(); int mFlag1 = mlogin.CheckLogin(txtUserEmail.Text, txtUserPassword.Text); //判断邮箱是否存在 if (mFlag1 == 1)//如果存在,跳转到个人主页 { AddFriend adf = new AddFriend(); string userid = txtUserEmail.Text.ToString(); Session["UserID"] = userid; Session["UserName"] = adf.SearchName(userid); if (Application[userid] == null) { XmlDataManager xdm = new XmlDataManager(); Application[userid] = xdm.InitialChatPrivateMessageXml; Response.Redirect("ChatPerhome.aspx");//跳转到个人主页 } else Response.Redirect("ChatPerhome.aspx");//跳转到个人主页 //Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script Language='javascript'>alert('用户已登录,不可以重复登录!')</script>"); } else//如果不存在,输出用户名或密码错误 { Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script Language='javascript'>alert('用户名或密码错误,请重新输入!')</script>"); } }
//XmlDataManager xdm; //xml数据管理对象 protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] != null) { AddFriend addf = new AddFriend(); lbUserName.Text = Session["UserName"].ToString(); string auserid = Session["UserID"].ToString(); System.Data.DataTable datatable = addf.FriendsList(auserid); this.Label5.InnerHtml = friendstring(datatable); } else { Response.Redirect("ChatLogin.aspx"); } }
//拒绝添加 protected void Button9_Click(object sender, EventArgs e) { AddFriend mAddFriend = new AddFriend(); mAddFriend.RefuseAddfriend(Session["UserID"].ToString(), DropDownList1.SelectedValue); Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script Language='javascript'>alert('已拒绝加为好友')</script>"); DropDownList1.Items.Remove(DropDownList1.Items.FindByValue(DropDownList1.SelectedValue));//按值删除 if (DropDownList1.Items.Count == 0) { this.Button7.Visible = false; this.DropDownList1.Visible = false; this.Button8.Visible = false; this.Button9.Visible = false; } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Regist mregist = new Regist(); int mFlag4 = mregist.CheckUserRegist(TextBox1.Text); if (mFlag4 == 1) //判断是否存在此用户 { AddFriend mAddFriend = new AddFriend(); int mAgine = mAddFriend.CheckAddFriendMessage(Session["UserID"].ToString(), TextBox1.Text); if (mAgine == 1) //判断是否已为好友 { Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script Language='javascript'>alert('该用户已为好友')</script>"); } else { int mWork = mAddFriend.AddFriends(Session["UserID"].ToString(), TextBox1.Text); if (mWork == 1) //添加好友 { Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script Language='javascript'>alert('等待对方回应')</script>"); } } } else { Page.ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script Language='javascript'>alert('您输入的邮箱不存在,请重新输入!')</script>"); } }
protected void Page_Load(object sender, EventArgs e) { Response.Buffer = true; //退出无法返回 Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1); Response.Expires = 0; Response.CacheControl = "no-cache"; if (Session["UserID"] == null) { Response.Redirect("ChatLogin.aspx"); } if (!IsPostBack) { SelfMessage mSelfMessage = new SelfMessage(); //显示个人信息 DataTable mMess = mSelfMessage.ShowSelfMessage(Session["UserID"].ToString()); this.text1.Text = mMess.Rows[0]["UserName"].ToString(); this.text2.Text =Session["UserID"].ToString(); this.text3.Text = mMess.Rows[0]["Remark"].ToString(); AddFriend mAddFriend = new AddFriend(); //显示添加信息 DataTable mGetM = mAddFriend.GetAddMessage(Session["UserID"].ToString()); if (mGetM.Rows.Count > 0) { this.Button7.Visible = true; DropDownList1.DataSource = mGetM; DropDownList1.DataTextField = "UserEmail"; DropDownList1.DataValueField = "UserEmail"; DropDownList1.DataBind(); } OfflineMessage mOfflineMessage = new OfflineMessage(); //显示离线信息 DataTable mGOffM = mOfflineMessage.GetOffMessage(Session["UserID"].ToString()); if (mGOffM.Rows.Count > 0) { this.Button6.Visible = true; this.TextBox3.Text = null; for (int i = 0; i < mGOffM.Rows.Count; i++) { this.TextBox3.Text += mGOffM.Rows[i]["SenderEmail"].ToString() +mGOffM.Rows[i]["Time"].ToString() + "说:\n" + mGOffM.Rows[i]["Message"].ToString() + "\n"; mOfflineMessage.DeleteOffMessage(Session["UserID"].ToString(), mGOffM.Rows[i]["SenderEmail"].ToString()); } } } }