MessageList.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:5k
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using qminoa.DA;
- using qminoa.Common.Data;
- using System.Windows.Forms;
- namespace qminoa.Webs.Msg
- {
- public class MessageList : qminoa.Webs.PageBase
- {
- private DataSet msgdata;
- public string msgbox = null;
- protected System.Web.UI.WebControls.Button btnRemain;
- protected System.Web.UI.WebControls.Button btnMove;
- protected System.Web.UI.WebControls.Button btnDelete;
- protected System.Web.UI.WebControls.DataGrid GridMain;
- protected System.Web.UI.WebControls.CheckBox sel;
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("信息箱",false);
- btnDelete.Attributes.Add("onclick", "return confirm('确定要彻底删除吗?');");
- btnMove.Attributes.Add("onclick", "return confirm('确定要删除至垃圾箱吗?');");
- btnRemain.Visible = false;
- msgbox = Request.QueryString["MsgBox"];
- if("recnote" == msgbox)
- {
- msgdata = (new MsgObj()).SeeMessage("recnote",Convert.ToInt16(this.Empid));
- }
- else if ("sendnote" == msgbox)
- {
- msgdata = (new MsgObj()).SeeMessage("sendnote",Convert.ToInt16(this.Empid));
- }
- else if("caonote" == msgbox)
- {
- msgdata = (new MsgObj()).SeeMessage("caonote",Convert.ToInt16(this.Empid));
- }
- else if("lanote" == msgbox)
- {
- msgdata = (new MsgObj()).SeeMessage("lanote",Convert.ToInt16(this.Empid));
- btnRemain.Visible = true;
- btnMove.Visible = false;
- }
- else
- {
- }
- FormatSource(msgdata);
- if(!IsPostBack)
- {
- GridMain.DataSource = msgdata;
- GridMain.DataBind();
- }
- if("lanote" == msgbox)
- {
- btnRemain.Visible = true;
- btnMove.Visible = false;
- }
- }
-
- public void FormatSource(DataSet msgdata)
- {
- string person;
- for( int i = 0; i < msgdata.Tables["simpleobj"].Rows.Count; i ++)
- {
- person = msgdata.Tables["simpleobj"].Rows[i]["SendTo"].ToString();
- if( "" == person)
- {
- msgdata.Tables["simpleobj"].Rows[i]["SendTo"] = msgdata.Tables["simpleobj"].Rows[i]["SecretTo"].ToString();
- }
- else
- {
- char [] seprator = new char [1];
- seprator[0] =',';
- if(person.IndexOf(",") != -1)
- {
- person = person.Split(seprator,10)[0]+ "...";
- }
- msgdata.Tables["simpleobj"].Rows[i]["SendTo"] = person;
- }
- string accessory = msgdata.Tables["simpleobj"].Rows[i]["Accessory"].ToString();
- if(accessory != "")
- {
- msgdata.Tables["simpleobj"].Rows[i]["Accessory"] = "<img src='image/doc.gif' border='0'>";
- }
- }
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.sel.CheckedChanged += new System.EventHandler(this.sel_CheckedChanged);
- this.GridMain.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.GridMain_PageIndexChanged);
- this.btnRemain.Click += new System.EventHandler(this.btnRemain_ServerClick);
- this.btnMove.Click += new System.EventHandler(this.btnMove_ServerClick);
- this.btnDelete.Click += new System.EventHandler(this.btnDelete_ServerClick);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void sel_CheckedChanged(object sender, System.EventArgs e)
- {
- foreach(DataGridItem thisItem in GridMain.Items)
- {
- ((System.Web.UI.WebControls.CheckBox)thisItem.Cells[0].Controls[1]).Checked = sel.Checked;
- }
- }
- private void GridMain_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
- {
- GridMain.CurrentPageIndex = e.NewPageIndex;
- GridMain.DataSource = msgdata;
- DataBind();
- }
- private void btnDelete_ServerClick(object sender, System.EventArgs e)
- {
- btn_Click("delete");
- }
- private void btnMove_ServerClick(object sender, System.EventArgs e)
- {
- btn_Click("move");
- }
- private void btnRemain_ServerClick(object sender, System.EventArgs e)
- {
- btn_Click("remain");
- }
- public void btn_Click(string type)
- {
- string MessageID;
- string Status;
- for(int i = 0; i < GridMain.Items.Count; i++)
- {
- if(((System.Web.UI.WebControls.CheckBox)GridMain.Items[i].Cells[0].Controls[1]).Checked)
- {
- MessageID = GridMain.Items[i].Cells[1].Text;
- Status = GridMain.Items[i].Cells[2].Text;
- switch(type)
- {
- case("delete"):
- (new MsgObj()).DeleteMessage(MessageID,this.Empid,Status);
- break;
- case("move"):
- (new MsgObj()).MoveMessage(MessageID,this.Empid,Status);
- break;
- case("remain"):
- (new MsgObj()).RemainMsg(MessageID,this.Empid,Status);
- break;
- default:
- break;
- }
-
- }
- }
- Response.Redirect("MessageList.aspx?MsgBox=" + msgbox);
- }
- }
- }