MailDesktop.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:2k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. public partial class MailDesktop : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         LoginLogic.MatchLoad("../", "MailDesktop");
  17.         Response.Redirect("ViewMail.aspx?FolderID=1");
  18. if(!Page.IsPostBack)
  19. {
  20. BindFolderData();
  21. }
  22.     }
  23. private void BindFolderData()
  24. {   ///获取数据
  25. IFolder folder = new Folder();
  26. SqlDataReader dr = folder.GetFolders();
  27. ///绑定数据
  28. FolderView.DataSource = dr;
  29. FolderView.DataBind();
  30. dr.Close();
  31. }
  32. protected void NewFolderBtn_Click(object sender,EventArgs e)
  33. {
  34. Response.Redirect("~/NewFolder.aspx");
  35. }
  36. protected void FolderView_RowCommand(object sender,GridViewCommandEventArgs e)
  37. {
  38. if(e.CommandName == "delete")
  39. {
  40. try
  41. {   ///删除数据
  42. IFolder folder = new Folder();
  43. folder.DeleteFolder(Int32.Parse(e.CommandArgument.ToString()));
  44. ///重新绑定控件的数据
  45. BindFolderData();
  46. Response.Write("<script>alert('" + "删除数据成功,请妥善保管好你的数据!" + "');</script>");
  47. }
  48. catch(Exception ex)
  49. {   ///跳转到异常错误处理页面
  50. Response.Redirect("ErrorPage.aspx?ErrorMsg=" + ex.Message.Replace("<br>","").Replace("n","")
  51. + "&ErrorUrl=" + Request.Url.ToString().Replace("<br>","").Replace("n",""));
  52. }
  53. }
  54. }
  55. protected void FolderView_RowDeleting(object sender,GridViewDeleteEventArgs e)
  56. {
  57. ///
  58. }
  59. protected void FolderView_RowDataBound(object sender,GridViewRowEventArgs e)
  60. {
  61. ImageButton deleteBtn = (ImageButton)e.Row.FindControl("DeleteBtn");
  62. if(deleteBtn != null)
  63. {
  64. deleteBtn.Attributes.Add("onclick","return confirm('你确定要删除所选择的数据项吗?');");
  65. }
  66. }
  67. }