// 修改密码 private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "") MessageBox.Show("必要信息不能为空!"); else { UserData userdata1 = new UserData(); User user = userdata1.GetUserByEmail(UserHelper.uEmail); if (textBox1.Text != user.PassWord) MessageBox.Show("密码输入错误!"); else if (textBox2.Text != textBox3.Text) MessageBox.Show("新密码的两次输入不一致!"); else { if (textBox1.Text == textBox2.Text) MessageBox.Show("新密码与旧密码相同,请重新输入!"); else { user.Email = UserHelper.uEmail; user.PassWord = textBox2.Text; userdata1.UpdateUser(user); if (user.PassWord == textBox3.Text) { MessageBox.Show("密码修改成功,请重新登录!"); Logging logging = new Logging(); logging.Show(); this.Hide(); } else MessageBox.Show("密码修改失败!"); } } } }
// 添加联系人 private void button2_Click(object sender, EventArgs e) { if (textBox1.Text.Length == 0) { MessageBox.Show("必要信息不能为空"); } else { Email.Domain.Entities.Linkman linkman = new Email.Domain.Entities.Linkman(); Email.Domain.Entities.Linkman linkman2 = new Email.Domain.Entities.Linkman(); Email.Domain.Entities.User user = new Email.Domain.Entities.User(); linkman.Receiver = textBox1.Text; linkman.Sender = UserHelper.uEmail; string id1 = textBox1.Text; linkman2.Receiver = UserHelper.uEmail; linkman2.Sender = textBox1.Text; user.Email = id1; string id2 = UserHelper.uEmail + textBox1.Text; string id22 = textBox1.Text + UserHelper.uEmail; linkman.LinkmanId = id2; linkman2.LinkmanId = id22; Email.Domain.Entities.User testuser; Email.Data.UserData userdata = new UserData(); testuser = userdata.GetUserByEmail(id1); Email.Domain.Entities.Linkman testlinkmans; testlinkmans = linkmandata.GetLinkmanByLinkmanId(id2); if (testuser == null) { MessageBox.Show("不存在该账号!"); } else { if (testlinkmans != null) { MessageBox.Show("该邮箱已是你的联系人"); } else { linkmandata.AddLinkman(linkman); linkmandata.AddLinkman(linkman2); Email.Domain.Entities.Linkman testlinkmans1 = linkmandata.GetLinkmanByLinkmanId(id2); if (testlinkmans1 != null) MessageBox.Show("添加成功!"); } } } }
// 注销账号 private void button2_Click(object sender, EventArgs e) { if (textBox4.Text == "") MessageBox.Show("请输入密码"); else { UserData userdata3 = new UserData(); MessageOutboxData messageoutboxdata = new MessageOutboxData(); MessageInboxData messageinboxdata = new MessageInboxData(); LinkmanData linkmandata = new LinkmanData(); User user = userdata3.GetUserByEmail(UserHelper.uEmail); if (textBox4.Text != user.PassWord) { MessageBox.Show("密码错误,请重新输入!"); textBox4.Clear(); } else { //User user = new User(); //user.Email = UserHelper.uEmail; //user.PassWord = textBox4.Text; userdata3.DeleteUser(user); linkmandata.DeleteAllLinkman(); messageinboxdata.DeleteAllMessageInbox(); messageoutboxdata.DeleteAllMessageOutbox(); //UserData userdata3 = new UserData(); User user1 = userdata3.GetUserByEmail(UserHelper.uEmail); if (user1 == null & messageinboxdata.GetAllMessageInbox().Count == 0 & messageoutboxdata.GetAllMessageOutbox().Count == 0 & linkmandata.GetAllLinkman().Count == 0) { MessageBox.Show("注销用户成功,并退出系统!"); textBox4.Clear(); this.Hide(); Logging logging = new Logging(); logging.Show(); } else MessageBox.Show("注销用户失败"); } } }