protected void submit_Click(object sender, EventArgs e) { var addnewcount = new User_Count() { Users_Name = username.Text, Users_Password = password.Text, Users_Phone = phone.Text, Users_Email = email.Text, Users_School = school.Text, Users_CreateTO = "", Users_TO = "", Users_Photo = "no", Users_Signature = "no", Users_StudyNumber = "" }; int adds = am.AddUser_Count(addnewcount); if (adds == 0) { Response.Write("<script>alert(' 该电话号码已存在')</script>"); } else if (adds == 1) { Response.Write("<script>alert('该邮箱已存在')</script>"); } else if (adds == 2) { Response.Write("<script>alert('数据异常请联系管理员')</script>"); } else { Response.Redirect("Login.aspx"); } }
public string UpdateUser(User_Count usercount) { var Re = context.User_Counts.FirstOrDefault(d => d.Users_Id == usercount.Users_Id); if (Re != null) { Re.Users_Name = usercount.Users_Name; Re.Users_Password = usercount.Users_Password; Re.Users_Phone = usercount.Users_Phone; Re.Users_Email = usercount.Users_Email; Re.Users_CreateTO = usercount.Users_CreateTO; Re.Users_TO = usercount.Users_TO; Re.Users_Photo = usercount.Users_Photo; Re.Users_Signature = usercount.Users_Signature; Re.Users_StudyNumber = usercount.Users_StudyNumber; Re.Users_School = usercount.Users_School; try { context.SaveChanges(); return("Success"); } catch (Exception) { return("error"); } } else { return("该用户不存在"); } }
public int AddUser_Count(User_Count usercount) { int phone = context.User_Counts.Where(p => p.Users_Phone == usercount.Users_Phone).Count(); int email = context.User_Counts.Where(p => p.Users_Phone == usercount.Users_Phone).Count(); if (phone > 0) { return(0); } else if (email > 0) { return(1); } else { var Usercount = new User_Count() { Users_Name = usercount.Users_Name, Users_Email = usercount.Users_Email, Users_Phone = usercount.Users_Phone, Users_Password = usercount.Users_Password, Users_CreateTO = usercount.Users_CreateTO, Users_TO = usercount.Users_TO, Users_Photo = usercount.Users_Photo, Users_Signature = usercount.Users_Signature, Users_StudyNumber = usercount.Users_StudyNumber, Users_School = usercount.Users_School }; context.Set <User_Count>().Add(Usercount); try { context.SaveChanges(); return(Usercount.Users_Id); } catch (Exception) { return(2); } } }
public string RemoveUser(User_Count usercount) { var Re = context.User_Counts.FirstOrDefault(d => d.Users_Id == usercount.Users_Id); if (Re != null) { try { context.User_Counts.Remove(Re); context.SaveChanges(); return("Success"); } catch (Exception) { return("error"); } } else { return("该用户不存在"); } }
public void ThreadOfEmail() { while (true) { if (ConfigList == null) { Thread.Sleep(ScanBetween); continue; } List <EmailConfig> eclist = new List <EmailConfig>(ConfigList); foreach (EmailConfig e in eclist) { try { EmailHelper eh = new EmailHelper(e); int count = eh.GetEmailCount(); eh.Disposed(); if (!Config_MD5.ContainsKey(e)) { Config_MD5.Add(e, e.GetMD5()); } if (!User_Count.ContainsKey(Config_MD5[e])) { User_Count.Add(Config_MD5[e], count); } else { #region 失效 //if (User_Count[Config_MD5[e]] != count) //{ // if (User_Count[Config_MD5[e]] > count) // { // NotifyIcon.ShowBalloonTip(5, "邮件被删除", e.Url + ":" + e.UserName + "删除了" + (count) + "条邮件", ToolTipIcon.Info); // } // else // { // NotifyIcon.ShowBalloonTip(5, "收到了新邮件", e.Url + ":" + e.UserName + "收到了" + (count - User_Count[Config_MD5[e]]) + "条新邮件", ToolTipIcon.Info); // } // User_Count[Config_MD5[e]] = User_Count[Config_MD5[e]] + count; //} #endregion } if (count != 0) { User_Count[Config_MD5[e]] = User_Count[Config_MD5[e]] + count; NotifyIcon.ShowBalloonTip(5, "收到了新邮件", e.Url + ":" + e.UserName + "收到了" + (count) + "条新邮件", ToolTipIcon.Info); if (!MailMessages.ContainsKey(Config_MD5[e])) { MailMessages.Add(Config_MD5[e], new List <MailMessage>()); } EmailHelper ehh = new EmailHelper(e); var ll = ehh.GetAllEmailMessages(); MailMessages[Config_MD5[e]].AddRange(ll); ehh.Disposed(); } else { ; } } catch { ConfigList.Remove(e); Config_MD5.Remove(e); } } Thread.Sleep(ScanBetween); } }