protected void btn1_Click(object sender, EventArgs e) { Hashtable ht = new Hashtable(); string[] arr1 = new string[] { "title", "remark" }; for (int i = 0; i < arr1.Length; i++) { ht.Add(arr1[i], Util.GetControlValue(this.to1.Parent.FindControl(arr1[i]))); } ht.Add("to1", this.to1.Text); ht.Add("time0", DateTime.Now.ToString()); ht.Add("from1", User.Identity.Name); if (ht["title"].ToString().Trim() == "" || ht["remark"].ToString().Trim() == "") { Util.alert(this.Page, "错误提示,请输入标题或正文"); } else { ZX_EmailBu email2 = new ZX_EmailBu(); bool result = email2.AddMailTwo(ht); if (result) { Response.Redirect("ReceiveMail.aspx", true); } else { Util.alert(this.Page, "错误提示:邮件发送失败!"); } } }
//向当前用户的直接领导发送邮件提醒功能 public static void SendMailToLeader(string title, string remark, string url) { string user1 = HttpContext.Current.User.Identity.Name; string leader = null; if (String.IsNullOrEmpty(user1) == false) { U_UserNameBU userBU = new U_UserNameBU(); leader = userBU.GetDirLeader(); userBU.Close(); } if (leader != null) { ZX_EmailBu email1 = new ZX_EmailBu(); Hashtable ht = new Hashtable(); ht["time0"] = System.DateTime.Now.ToString(); ht["title"] = title; ht["remark"] = remark; ht["from1"] = user1; ht["to1"] = leader; ht["back"] = "1"; ht["url"] = url; email1.AddMail(ht); email1.Close(); } }
//显示数据 private void BindData() { ZX_EmailBu email = new ZX_EmailBu(); bool huizhi = email.getHuiZhi(Request.QueryString["id"]); if (huizhi) { this.hidHuiZhi.Value = Request.QueryString["id"]; } DataSet ds1 = email.GetUserMail(Request.QueryString["id"]); this.mailForm1.DataSource = ds1; if (ds1.Tables[0].Rows[0]["remark"] != DBNull.Value) { ds1.Tables[0].Rows[0]["remark"] = ds1.Tables[0].Rows[0]["remark"].ToString(); //if (huizhi == false) //{ // ds1.Tables[0].Rows[0]["remark"] = Util.ChangeToShow(ds1.Tables[0].Rows[0]["remark"].ToString()); //} //else //{ // ds1.Tables[0].Rows[0]["remark"] = ds1.Tables[0].Rows[0]["remark"].ToString(); //} } this.mailForm1.DataBind(); email.Close(); }
//提交批阅意见 protected void Button1_Click(object sender, EventArgs e) { ZX_EmailBu email1 = new ZX_EmailBu(); string id = Request.QueryString["id"]; email1.setReplyEmail(id, this.TextBox1.Text); email1.Close(); Response.Write("<br><br><br><br><br><br><center><font size='4'>您的信息已提交,请关闭窗口!<font></center>"); Response.End(); }
//得到最新的邮件ID信息 private void GetNewEmail() { ZX_EmailBu email1 = new ZX_EmailBu(); int mailid = email1.GetNewMailID(); if (mailid != 0) { this.NewEmailID.Value = mailid + ""; } else { this.NewEmailID.Value = ""; } email1.Close(); }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { ZX_EmailBu email1 = new ZX_EmailBu(); if (e.Row.DataItem != null) { DataRow dr = ((DataRowView)e.Row.DataItem).Row; if (email1.IfRead(dr["id"].ToString())) { ((Image)e.Row.FindControl("img1")).Visible = false; } else { ((Image)e.Row.FindControl("img1")).ImageUrl = "~/Common/Image/mail_open.gif"; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_RolesBU role1 = new U_RolesBU(); bool isLeader = role1.isRole(new String[] { "公司领导", "综合管理", "评审部角色" }); role1.Close(); if (isLeader) { Response.Redirect("~/ZcMng1/ZongHeSearch.aspx", true); } else { this.BindData(null); //设置时效警告、邮件、最新信息的提示数据 U_ZCTimeBU time1 = new U_ZCTimeBU(); DataSet ds1 = time1.GetMyTimeList(User.Identity.Name, null, 1); this.MyTimeCount.Value = ds1.Tables[0].Rows.Count + ""; time1.Close(); ZX_EmailBu email1 = new ZX_EmailBu(); this.MyEmail.Value = email1.GetNewMailCount() + ""; email1.Close(); ZX_InfoBU info1 = new ZX_InfoBU(); this.MyInfo.Value = info1.GetNewInfoCount() + ""; info1.Close(); if ((this.MyTimeCount.Value != "0" || this.MyEmail.Value != "0" || this.MyInfo.Value != "0") && Session["noReminder_" + User.Identity.Name] == null && Request.Cookies["noReminder_" + User.Identity.Name] == null) { string js = "StartReminder();"; if (!Page.ClientScript.IsStartupScriptRegistered("StartJS")) { Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "StartJS", js, true); } } } } this.AdvanceSearch1.SetDepartRow(false); this.AdvanceSearch1.OnMySearchClick += new EventHandler(AdvanceSearch1_OnMySearchClick); this.SearchControl1.SearchEvent += new EventHandler(SearchControl1_SearchEvent); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["EmailID"] != null) { ZX_EmailBu email1 = new ZX_EmailBu(); Hashtable ht = email1.GetMailDetailByID(Request.QueryString["EmailID"]); if (ht.Count > 0) { this.from1.Text = ht["from1"].ToString(); this.fromtime.Text = ht["time0"].ToString(); this.subject.Text = ht["title"].ToString(); } email1.Close(); } } }
//bind data private void BindData() { ZX_EmailBu email1 = new ZX_EmailBu(); int totalRow = 0; int curpage = 1; if (ViewState["curpage"] != null) { curpage = (int)ViewState["curpage"]; } string orderby = null; if (ViewState["orderby"] != null) { orderby = ((SqlOrderBy)(ViewState["orderby"])).OrderExpression; } DataSet ds1 = email1.GetUserMail(curpage, this.PageNavigator1.PageSize, orderby, out totalRow); this.GridView1.DataSource = ds1; this.GridView1.DataBind(); this.PageNavigator1.TotalRows = totalRow; this.PageNavigator1.CurrentPage = curpage; if (ds1.Tables[0].Rows.Count == 0 && curpage > 1) { ViewState["curpage"] = curpage - 1; this.BindData(); } //隐藏删除等控件 if (totalRow > 0) { this.info2.Visible = true; } else { this.info2.Visible = false; } email1.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ZX_EmailBu email1 = new ZX_EmailBu(); this.newmail.Text = email1.GetNewMailCount() + ""; email1.Close(); ZX_InfoBU info1 = new ZX_InfoBU(); this.newinfo.Text = info1.GetNewInfoCount() + ""; info1.Close(); U_ZCTimeBU time1 = new U_ZCTimeBU(); DataSet ds1 = time1.GetMyTimeList(User.Identity.Name, null, 1); this.MyTime.Text = ds1.Tables[0].Rows.Count + ""; ds1.Dispose(); time1.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //邮件提醒功能 ZX_EmailBu email1 = new ZX_EmailBu(); int mailid = email1.GetNewMailID(); if (mailid != 0) { this.NewEmailID.Value = mailid + ""; } else { this.NewEmailID.Value = ""; } email1.Close(); this.GetNewMessage(); } }
//删除邮件 protected void Button1_Click(object sender, EventArgs e) { ZX_Email1BU emal1 = new ZX_Email1BU(); string id = Request.QueryString["id"]; DataSet ds1 = emal1.GetSendMail(id); string file1 = ds1.Tables[0].Rows[0]["file1"].ToString(); if (file1 != "" && file1 != null) { ZX_EmailBu email1 = new ZX_EmailBu(); bool Cunzai = email1.IfCzFile(file1, "1"); if (Cunzai == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file1)); } email1.Dispose(); } string file2 = ds1.Tables[0].Rows[0]["file2"].ToString(); if (file2 != "" && file2 != null) { ZX_EmailBu email2 = new ZX_EmailBu(); bool Cunzai2 = email2.IfCzFile(file2, "2"); if (Cunzai2 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file2)); } email2.Dispose(); } string file3 = ds1.Tables[0].Rows[0]["file3"].ToString(); if (file3 != "" && file3 != null) { ZX_EmailBu email3 = new ZX_EmailBu(); bool Cunzai3 = email3.IfCzFile(file3, "3"); if (Cunzai3 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file3)); } email3.Dispose(); } string file4 = ds1.Tables[0].Rows[0]["file4"].ToString(); if (file4 != "" && file4 != null) { ZX_EmailBu email4 = new ZX_EmailBu(); bool Cunzai4 = email4.IfCzFile(file4, "4"); if (Cunzai4 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file4)); } email4.Dispose(); } string file5 = ds1.Tables[0].Rows[0]["file5"].ToString(); if (file5 != "" && file5 != null) { ZX_EmailBu email5 = new ZX_EmailBu(); bool Cunzai5 = email5.IfCzFile(file5, "5"); if (Cunzai5 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file5)); } email5.Dispose(); } emal1.DelMail(id); emal1.Close(); Comm.ShowInfo("操作提示:删除留言数据成功!", Application["root"] + "/info/SendMail.aspx"); }
protected void btn1_Click(object sender, EventArgs e) { if (Page.IsValid) { //如果是转发邮件,需要判断邮件的数量(2008年6月1日) //编码:金寿吉 时间:2008年6月1日 /*----判断上传附件的数量---------*/ int MaxFile = 0; int begin = 0; String[] TranFile = new String[5]; if (Request.QueryString["inboxid"] != null) { foreach (RepeaterItem item in this.tranReapeater.Items) { CheckBox chk1 = item.FindControl("chkfile") as CheckBox; if (chk1.Checked) { Label lab2 = item.FindControl("labTransFile") as Label; TranFile[begin] = lab2.Text; //保存转发的附件 MaxFile++; begin++; } } //累计用户上传的附件 if (MaxFile <= 5) { for (int i = 1; i <= 5; i++) { FileUpload file = this.FileUpload1.Parent.FindControl("FileUpload" + i) as FileUpload; if (file != null && file.PostedFile != null && file.PostedFile.FileName != String.Empty) { MaxFile++; } } } } //处理附件上传 if (MaxFile <= 5) { Hashtable ht = new Hashtable(); ht["to1"] = this.to1.Text; ht["title"] = this.title.Text.Trim(); ht["remark"] = this.remark.Text; ht["time0"] = DateTime.Now.ToString(); ht["from1"] = User.Identity.Name; //处理转发的附件 int hbegin = 1; for (int i = 0; i < TranFile.Length; i++) { if (TranFile[i] != null && TranFile[i] != String.Empty) { ht["file" + hbegin] = TranFile[i]; hbegin++; } } //处理上传的附件 if (this.FileUpload1.PostedFile != null) { string ExcelName1 = FileUpload1.PostedFile.FileName; string file1 = User.Identity.Name + "_" + Util.GetRandomString(9) + "_" + Path.GetFileName(ExcelName1); if (Path.GetFileName(ExcelName1) != "") { ht["file" + hbegin] = file1; FileUpload1.PostedFile.SaveAs(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file1)); hbegin++; } } if (this.FileUpload2.PostedFile != null) { string ExcelName2 = FileUpload2.PostedFile.FileName; string file2 = User.Identity.Name + "_" + Util.GetRandomString(9) + "_" + Path.GetFileName(ExcelName2); if (Path.GetFileName(ExcelName2) != "") { ht["file" + hbegin] = file2; FileUpload2.PostedFile.SaveAs(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file2)); hbegin++; } } if (this.FileUpload3.PostedFile != null) { string ExcelName3 = FileUpload3.PostedFile.FileName; string file3 = User.Identity.Name + "_" + Util.GetRandomString(9) + "_" + Path.GetFileName(ExcelName3); if (Path.GetFileName(ExcelName3) != "") { ht["file" + hbegin] = file3; FileUpload3.PostedFile.SaveAs(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file3)); hbegin++; } } if (this.FileUpload4.PostedFile != null) { string ExcelName4 = FileUpload4.PostedFile.FileName; string file4 = User.Identity.Name + "_" + Util.GetRandomString(9) + "_" + Path.GetFileName(ExcelName4); if (Path.GetFileName(ExcelName4) != "") { ht["file" + hbegin] = file4; FileUpload4.PostedFile.SaveAs(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file4)); hbegin++; } } if (this.FileUpload5.PostedFile != null) { string ExcelName5 = FileUpload5.PostedFile.FileName; string file5 = User.Identity.Name + "_" + Util.GetRandomString(9) + "_" + Path.GetFileName(ExcelName5); if (Path.GetFileName(ExcelName5) != "") { ht["file" + hbegin] = file5; FileUpload5.PostedFile.SaveAs(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file5)); hbegin++; } } //发送邮件操作 ZX_EmailBu email2 = new ZX_EmailBu(); bool result = false; result = email2.AddMailTwo(ht); if (result) { PubComm.ShowInfo("操作提示:邮件发送成功!", Application["root"] + "/Info/SendMail.aspx"); } else { Util.alert(this.Page, "错误提示:邮件发送失败!"); } } else { Util.alert(this.Page, "错误提示:上传的附件数量不等超过5个!"); } } }
//设置邮件信息 private void setMail() { DataSet ds1 = null; string id = null; if (Request.QueryString["tousers"] != null) { this.to1.Text = Server.UrlDecode(Request.QueryString["tousers"]); } if (Request.QueryString["sendid"] != null || Request.QueryString["inboxid"] != null) { //来自发件箱 if (Request.QueryString["sendid"] != null) { id = Request.QueryString["sendid"]; ZX_Email1BU email1 = new ZX_Email1BU(); ds1 = email1.GetSendMail(id); email1.Close(); } else { //来自收件箱 id = Request.QueryString["inboxid"]; ZX_EmailBu email2 = new ZX_EmailBu(); ds1 = email2.GetUserMail(id); email2.Close(); } } if (ds1 != null) { DataRow dr = ds1.Tables[0].Rows[0]; if (Request["back"] != null) { this.Title = "回复邮件"; //回复邮件 this.title.Text = "回复:" + dr["title"].ToString(); this.to1.Text = dr["from1"].ToString(); if (dr["remark"] != DBNull.Value) { this.remark.Text = "<br><br><b>原邮件内容</b>:<br><hr>" + dr["remark"].ToString(); } } else if (Request["transfer"] != null) { this.Title = "转发邮件"; //转发邮件 this.title.Text = "转发:" + dr["title"].ToString(); if (dr["remark"] != DBNull.Value) { this.remark.Text = dr["remark"].ToString(); } //设置转发邮件列表(2008年6月1日) //编码:金寿吉 时间:2008年6月1日 /*----设置转发邮件---------*/ DataTable FileTable = ViewState["FileTable"] as DataTable; if (FileTable == null) { FileTable = new DataTable(); FileTable.Columns.Add("FileName"); FileTable.Columns.Add("FileName1"); for (int i = 1; i <= 5; i++) { if (dr["file" + i].ToString().Trim() != String.Empty) { DataRow dr1 = FileTable.NewRow(); dr1["FileName"] = dr["file" + i].ToString().Trim(); dr1["FileName1"] = dr["file" + i].ToString().Trim().Split('_')[2]; FileTable.Rows.Add(dr1); } } ViewState["FileTable"] = FileTable; } if (FileTable.Rows.Count > 0) { this.transRow.Visible = true; this.tranReapeater.DataSource = FileTable; this.tranReapeater.DataBind(); } /*----设置转发邮件---------*/ } else if (Request["again"] != null) { this.Title = "重发邮件"; //重发邮件 this.title.Text = dr["title"].ToString(); this.to1.Text = dr["to1"].ToString(); if (dr["remark"] != DBNull.Value) { this.remark.Text = dr["remark"].ToString(); } } else { ; } } }
//del mail protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString(); ZX_EmailBu emal1 = new ZX_EmailBu(); DataSet ds1 = emal1.GetUserMail(id); string file1 = ds1.Tables[0].Rows[0]["file1"].ToString(); if (file1 != "" && file1 != null) { ZX_Email1BU email1 = new ZX_Email1BU(); bool Cunzai = email1.IfCzFile(file1, "1"); if (Cunzai == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file1)); } email1.Dispose(); } string file2 = ds1.Tables[0].Rows[0]["file2"].ToString(); if (file2 != "" && file2 != null) { ZX_Email1BU email2 = new ZX_Email1BU(); bool Cunzai2 = email2.IfCzFile(file2, "2"); if (Cunzai2 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file2)); } email2.Dispose(); } string file3 = ds1.Tables[0].Rows[0]["file3"].ToString(); if (file3 != "" && file3 != null) { ZX_Email1BU email3 = new ZX_Email1BU(); bool Cunzai3 = email3.IfCzFile(file3, "3"); if (Cunzai3 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file3)); } email3.Dispose(); } string file4 = ds1.Tables[0].Rows[0]["file4"].ToString(); if (file4 != "" && file4 != null) { ZX_Email1BU email4 = new ZX_Email1BU(); bool Cunzai4 = email4.IfCzFile(file4, "4"); if (Cunzai4 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file4)); } email4.Dispose(); } string file5 = ds1.Tables[0].Rows[0]["file5"].ToString(); if (file5 != "" && file5 != null) { ZX_Email1BU email5 = new ZX_Email1BU(); bool Cunzai5 = email5.IfCzFile(file5, "5"); if (Cunzai5 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file5)); } email5.Dispose(); } emal1.DelMail(id); this.BindData(); emal1.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request["kind"] != null && Request["kind"] == "1") { ZX_EmailBu Email = new ZX_EmailBu(); DataSet ds1 = Email.GetUserMail1(Request["id"].ToString()); for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) { string file1 = ds1.Tables[0].Rows[i]["file1"].ToString(); if (file1 != "" && file1 != null) { ZX_Email1BU email1 = new ZX_Email1BU(); bool Cunzai = email1.IfCzFile(file1, "1"); if (Cunzai == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file1)); } email1.Dispose(); } string file2 = ds1.Tables[0].Rows[i]["file2"].ToString(); if (file2 != "" && file2 != null) { ZX_Email1BU email2 = new ZX_Email1BU(); bool Cunzai2 = email2.IfCzFile(file2, "2"); if (Cunzai2 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file2)); } email2.Dispose(); } string file3 = ds1.Tables[0].Rows[i]["file3"].ToString(); if (file3 != "" && file3 != null) { ZX_Email1BU email3 = new ZX_Email1BU(); bool Cunzai3 = email3.IfCzFile(file3, "3"); if (Cunzai3 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file3)); } email3.Dispose(); } string file4 = ds1.Tables[0].Rows[i]["file4"].ToString(); if (file4 != "" && file4 != null) { ZX_Email1BU email4 = new ZX_Email1BU(); bool Cunzai4 = email4.IfCzFile(file4, "4"); if (Cunzai4 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file4)); } email4.Dispose(); } string file5 = ds1.Tables[0].Rows[i]["file5"].ToString(); if (file5 != "" && file5 != null) { ZX_Email1BU email5 = new ZX_Email1BU(); bool Cunzai5 = email5.IfCzFile(file5, "5"); if (Cunzai5 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file5)); } email5.Dispose(); } string id = ds1.Tables[0].Rows[i]["id"].ToString(); Email.DelMail(id); Email.Close(); } Response.Redirect("ReceiveMail.aspx", false); } else if (Request["kind"] != null && Request["kind"] == "2") { ZX_Email1BU emal1 = new ZX_Email1BU(); DataSet ds1 = emal1.GetSendMail1(Request["id"].ToString()); for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) { string file1 = ds1.Tables[0].Rows[0]["file1"].ToString(); if (file1 != "" && file1 != null) { ZX_EmailBu email1 = new ZX_EmailBu(); bool Cunzai = email1.IfCzFile(file1, "1"); if (Cunzai == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file1)); } email1.Dispose(); } string file2 = ds1.Tables[0].Rows[0]["file2"].ToString(); if (file2 != "" && file2 != null) { ZX_EmailBu email2 = new ZX_EmailBu(); bool Cunzai2 = email2.IfCzFile(file2, "2"); if (Cunzai2 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file2)); } email2.Dispose(); } string file3 = ds1.Tables[0].Rows[0]["file3"].ToString(); if (file3 != "" && file3 != null) { ZX_EmailBu email3 = new ZX_EmailBu(); bool Cunzai3 = email3.IfCzFile(file3, "3"); if (Cunzai3 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file3)); } email3.Dispose(); } string file4 = ds1.Tables[0].Rows[0]["file4"].ToString(); if (file4 != "" && file4 != null) { ZX_EmailBu email4 = new ZX_EmailBu(); bool Cunzai4 = email4.IfCzFile(file4, "4"); if (Cunzai4 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file4)); } email4.Dispose(); } string file5 = ds1.Tables[0].Rows[0]["file5"].ToString(); if (file5 != "" && file5 != null) { ZX_EmailBu email5 = new ZX_EmailBu(); bool Cunzai5 = email5.IfCzFile(file5, "5"); if (Cunzai5 == false) { File.Delete(Server.MapPath(Application["root"] + "/Common/MailFiles/" + file5)); } email5.Dispose(); } string id = ds1.Tables[0].Rows[i]["id"].ToString(); emal1.DelMail(id); emal1.Close(); } Response.Redirect("SendMail.aspx", false); } } }