- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- 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.Schedule;
- namespace qminoa.Webs.Schedule
- {
- /// <summary>
- /// Note 的摘要说明。
- /// </summary>
- public class Note : qminoa.Webs.PageBase
- {
- protected System.Web.UI.WebControls.Label lblUName;
- protected System.Web.UI.WebControls.DataGrid dgdData;
- protected System.Web.UI.WebControls.HyperLink lnkExit;
- protected System.Web.UI.WebControls.HyperLink lnkAdd;
- private DataTable olddatatable = new DataTable();
- private static DataTable newdatatable = new DataTable();
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("我的便笺",false);
- if(!IsPostBack)
- {
- //清除静态变量newdatatable的数据,否则出现页码错误
- newdatatable.Clear();
- //清除静态变量newdatatable,否则会出现列重复添加的错误
- newdatatable.Columns.Clear();
- NoteDataBind();
- }
- }
- private void NoteDataBind()
- {
- newdatatable.Columns.Add("content1");
- newdatatable.Columns.Add("content2");
- newdatatable.Columns.Add("content3");
- newdatatable.Columns.Add("content4");
- newdatatable.Columns.Add("content5");
- newdatatable.Columns.Add("id1");
- newdatatable.Columns.Add("id2");
- newdatatable.Columns.Add("id3");
- newdatatable.Columns.Add("id4");
- newdatatable.Columns.Add("id5");
- NoteDA objnote = new NoteDA();
- olddatatable = objnote.noteread(Convert.ToInt16(this.Empid)).Tables["note5"];
- for(int i = 0; i < olddatatable.Rows.Count; i ++)
- {
- if(i%5 == 0)
- {
- DataRow dr = newdatatable.NewRow();
- newdatatable.Rows.Add(dr);
- if(olddatatable.Rows[i][0].ToString().Length < 9)
- {
- newdatatable.Rows[(int)i/5]["content1"] ="<img src=../img/button/note.gif border=0>"+ "<br>"+olddatatable.Rows[i][0].ToString()+"...";
- }
- else
- {
- newdatatable.Rows[(int)i/5]["content1"] = "<img src=../img/button/note.gif border=0>"+"<br>"+olddatatable.Rows[i][0].ToString().Substring(0,9)+"...";
- }
- newdatatable.Rows[(int)i/5]["id1"] = olddatatable.Rows[i][1].ToString();
- }
- else if(i%5 == 1)
- {
- if(olddatatable.Rows[i][0].ToString().Length < 9)
- {
- newdatatable.Rows[(int)i/5]["content2"] = "<img src=../img/button/note.gif border=0>"+"<br>"+olddatatable.Rows[i][0].ToString()+"...";
- }
- else
- {
- newdatatable.Rows[(int)i/5]["content2"] = "<img src=../img/button/note.gif border=0>"+"<br>"+olddatatable.Rows[i][0].ToString().Substring(0,9)+"...";
- }
- newdatatable.Rows[(int)i/5]["id2"] = olddatatable.Rows[i][1].ToString();
- }
- else if(i%5 == 2)
- {
- if(olddatatable.Rows[i][0].ToString().Length < 9)
- {
- newdatatable.Rows[(int)i/5]["content3"] = "<img src=../img/button/note.gif border=0>"+ "<br>"+olddatatable.Rows[i][0].ToString()+"...";
- }
- else
- {
- newdatatable.Rows[(int)i/5]["content3"] = "<img src=../img/button/note.gif border=0>"+"<br>"+olddatatable.Rows[i][0].ToString().Substring(0,9)+"...";
- }
- newdatatable.Rows[(int)i/5]["id3"] = olddatatable.Rows[i][1].ToString();
- }
- else if(i%5 == 3)
- {
- if(olddatatable.Rows[i][0].ToString().Length < 9)
- {
- newdatatable.Rows[(int)i/5]["content4"] = "<img src=../img/button/note.gif border=0>"+"<br>"+olddatatable.Rows[i][0].ToString()+"...";
- }
- else
- {
- newdatatable.Rows[(int)i/5]["content4"] = "<img src=../img/button/note.gif border=0>"+"<br>"+olddatatable.Rows[i][0].ToString().Substring(0,9)+"...";
- }
- newdatatable.Rows[(int)i/5]["id4"] = olddatatable.Rows[i][1].ToString();
- }
- else if(i%5 == 4)
- {
- if(olddatatable.Rows[i][0].ToString().Length < 9)
- {
- newdatatable.Rows[(int)i/5]["content5"] = "<img src=../img/button/note.gif border=0>"+"<br>"+olddatatable.Rows[i][0].ToString()+"...";
- }
- else
- {
- newdatatable.Rows[(int)i/5]["content5"] = "<img src=../img/button/note.gif border=0>"+"<br>"+olddatatable.Rows[i][0].ToString().Substring(0,9)+"...";
- }
- newdatatable.Rows[(int)i/5]["id5"] = olddatatable.Rows[i][1].ToString();
- }
- }
- dgdData.DataSource = newdatatable;
- dgdData.DataBind();
- }
- private void dgdData_PageIndexChanged(object sender, DataGridPageChangedEventArgs e)
- {
- dgdData.CurrentPageIndex=e.NewPageIndex;
- dgdData.DataSource = newdatatable;
- dgdData.DataBind();
- }
- #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.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void dgdData_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
- {
- ListItemType itemType = e.Item.ItemType;
- e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';" ;
- if (itemType == ListItemType.Item )
- {
- e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#dedfde';";
- }
- else if( itemType == ListItemType.AlternatingItem)
- {
- e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
- }
- }
- }
- }