/// <summary> /// 发送邮件并保存到服务器 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { //获得所需参数 string strTo = tb_toname.Text.Trim(); strToIds = id_toValue.Value.Trim(); string strTitle = tb_Title.Text.Trim(); string strContent = tb_content.Text.Trim().Replace("\r\n", @"<br \>").Replace("原信息内容:", ""); HttpPostedFile hpf = file1.PostedFile; if (Convert.ToDouble(hpf.ContentLength) / 1024 / 1024 > 10) { Response.Write("<script>alert('附件大小不能大于10MB');</script>"); return; } else { CreateMdAndFilePaht(hpf); } //写入数据库 Tunnel.BLL.Tunnel_mail rbll = new Tunnel.BLL.Tunnel_mail(); Tunnel.Model.Tunnel_mail model = new Tunnel.Model.Tunnel_mail(); model.m_title = strTitle; model.m_content = strContent; model.m_file = filePaht; model.m_time = DateTime.Now; model.m_from = ul.LoginID; model.m_sort = 0; // 0未删除、1删除 model.m_state = 0; // 0未读、1已读 model.m_Ip = Tunnel.Common.Common.GetIp(); if (strToIds.LastIndexOf(',') > 0) { strToIds = strToIds.Remove(strToIds.LastIndexOf(','), 1); } string[] arr = strToIds.Split(','); int relt1 = -1; foreach (string s in arr) { bool state = true; for (int i = 1; i <= 2; i++) { if (i == 1) { model.m_Main = 1; //标记是自己发的 model.m_to = Convert.ToInt32(s); relt1 = rbll.Add(model); } else { model.m_Main = 0; //标记是发给别人的 model.m_to = Convert.ToInt32(s); relt1 = rbll.Add(model); //-------添加消息提示-------- Tunnel.Model.Tunnel_Remind remindmodel = new Tunnel.Model.Tunnel_Remind(); remindmodel.m_isread = 0; remindmodel.m_time = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); remindmodel.m_title = "新的站内消息,发件人:" + ul.getUserModel(model.m_from).m_name + "。时间:" + DateTime.Now + "<font color=red>(未读)</font>"; remindmodel.m_touser = model.m_to; remindmodel.m_url = "N_Exchange/N_Message/N_MessageView.aspx?Id=" + relt1; remindmodel.m_type = 2; remindmodel.m_typeid = relt1; remindmodel.m_callTime = Convert.ToDateTime("1800-01-01"); Tunnel.BLL.Tunnel_Remind rd = new Tunnel.BLL.Tunnel_Remind(); rd.Add(remindmodel); } if (relt1 == 0) { state = false; break; } } if (state == false) { break; } } string str = "站内信息发送"; string url = "N_MessageOld.aspx"; if (relt1 > 0) { str += "成功!"; } else { str += "失败!"; } MessageBox(str, url); }
public void NewSh() { if (Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); int i_hit = 0; string str1 = ""; if (RadioButton2.Checked) { i_hit = 1; str1 = "已通过审核"; } if (RadioButton1.Checked) { i_hit = 2; str1 = "审核已被驳回"; } string strsql = "update tunnel_information set i_hit=" + i_hit.ToString() + " where i_id=" + id.ToString(); int result = Tunnel.Data.DbHelperSQL.ExecuteSql(strsql); string str = ""; if (result > 0) { str = "提交成功"; PageBind(); } else { str = "提交失败"; } string strsql2 = "delete tunnel_remind where m_typeid=" + id.ToString() + " and m_type=4"; Tunnel.Data.DbHelperSQL.ExecuteSql(strsql2); Tunnel.Common.Message.Show(str); Tunnel_log model = new Tunnel_log(); model.l_content = "系统管理>>新闻管理>>审核新闻新闻,id:" + id; model.l_ip = Tunnel.Common.Common.GetIp(); model.l_time = DateTime.Now; model.l_user = ul.LoginID; model.l_sort = 3; Tunnel.BLL.Tunnel_log log = new Tunnel.BLL.Tunnel_log(); log.Add(model); strsql = "select * from tunnel_information where i_id=" + id; SqlDataReader reader = Tunnel.Data.DbHelperSQL.ExecuteReader(strsql); int touserId = 0; string titles = ""; if (reader.Read()) { touserId = Convert.ToInt32(reader["i_user"]); titles = reader["i_title"].ToString(); } if (touserId > 0 && touserId != ul.LoginID) { Tunnel.BLL.Tunnel_mail rbll = new Tunnel.BLL.Tunnel_mail(); Tunnel.Model.Tunnel_mail modelm = new Tunnel.Model.Tunnel_mail(); modelm.m_title = "新闻" + str1; modelm.m_content = "您发布的新闻:" + titles + "。" + str1; modelm.m_file = ""; modelm.m_time = DateTime.Now; modelm.m_from = ul.LoginID; modelm.m_sort = 0; // 0未删除、1删除 modelm.m_state = 0; // 0未读、1已读 modelm.m_Ip = Tunnel.Common.Common.GetIp(); int relt1 = -1; for (int i = 1; i <= 2; i++) { if (i == 1) { modelm.m_Main = 1; //标记是自己发的 modelm.m_to = Convert.ToInt32(touserId); relt1 = rbll.Add(modelm); } else { modelm.m_Main = 0; //标记是发给别人的 modelm.m_to = Convert.ToInt32(touserId); relt1 = rbll.Add(modelm); } } } } }