DepSchByDay.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:10k
- 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;
- namespace qminoa.Webs.Schedule
- {
- /// <summary>
- /// 孙强
- /// </summary>
- public class DepSchByDay : System.Web.UI.Page
- {
- protected System.Web.UI.WebControls.Label lblUName;
- protected System.Web.UI.WebControls.DropDownList dropBranch;
- protected System.Web.UI.WebControls.DropDownList dropDep;
- protected System.Web.UI.WebControls.ImageButton cmdQuery;
- protected System.Web.UI.WebControls.DropDownList dropMonth;
- protected System.Web.UI.WebControls.DropDownList dropDay;
- protected System.Web.UI.WebControls.Label lblErr;
- protected System.Web.UI.WebControls.TextBox dropName;
- protected System.Web.UI.WebControls.TextBox dropYear;
- //注释
- protected static DataView branchView;
- protected static DataView depView;
- protected static ListItem item;
- protected System.Web.UI.WebControls.Label lblEmpNum;
- protected System.Web.UI.WebControls.Label lblDate;
- protected System.Web.UI.WebControls.LinkButton cmdToday;
- protected System.Web.UI.WebControls.HyperLink lnkByWeek;
- protected System.Web.UI.WebControls.HyperLink lnkByDay;
- protected System.Web.UI.WebControls.LinkButton cmdLastDay;
- protected System.Web.UI.WebControls.Label lblHeader;
- protected System.Web.UI.WebControls.LinkButton cmdNextDay;
- protected System.Web.UI.WebControls.Label lblJt;
- protected System.Web.UI.WebControls.Label lblJs;
- protected System.Web.UI.WebControls.Label lblCf;
- protected System.Web.UI.WebControls.Label lblOther;
- protected System.Web.UI.WebControls.Label lblSum;
- protected System.Web.UI.WebControls.DataGrid DataGrid3;
- protected static AccessDb accessDb = new AccessDb();
- protected static DateTime date;
- protected TimeSpan mySpan = new TimeSpan(1,0,0,0,0);
- protected static DataSet mySet;
- //测试变量
- protected static string tempStr;
- protected int pageSize = 0;
- protected int rowNum;
- protected bool search_Flag;
- protected System.Web.UI.WebControls.DataGrid dgdData;
- protected int myEmpID;
-
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (!IsPostBack)
- {
- date = DateTime.Now;
- dropYear.Text = date.Year.ToString();;
- dropMonth.Items[Convert.ToInt32(date.Month)-1].Selected = true;
- dropDay.Items[Convert.ToInt32(date.Day)-1].Selected = true;
- }
-
- //初始化组合框
- ComposeSearchInit();
- //返回数据放入内存
- returnDataSet();
- //创建DataSet内表的关系
- CreateRelation("EmpID_DepSch");
- lblHeader.Text = DateTime.Now.Date.ToString("D");
- search_Flag = false;
- // date = DateTime.Now.Date;
- // 在此处放置用户代码以初始化页面
- //if (!IsPostBack)
- //{
- //BindData();
-
- //}
- dgdData.DataSource = mySet.Tables["empTable"];
- dgdData.DataKeyField = "EmpID";
- dgdData.DataBind();
-
- }
- //对组合查询框进行初始化
- protected void ComposeSearchInit()
- {
- item = new ListItem();
- item.Text = "选择全部";
- item.Value = "0";
- //执行存储过程 cpBranch_List
- //返回有关 "机构表" 数据
- accessDb.SendStoredProcedure("cpBranch_List");
- branchView = accessDb.ReturnDataViewResult();
- branchView.AddNew();
- branchView[branchView.Count-1]["BranchName"] = "--选择全部--";
- branchView[branchView.Count-1]["BranchID"] = "0";
- //设置"机构名称"下拉列表的属性
- dropBranch.AutoPostBack = true;
- dropBranch.Items.Add(item);
- //"机构名称"下拉列表数据源绑定
- dropBranch.DataSource = branchView;
- dropBranch.DataTextField = "BranchName";
- dropBranch.DataValueField = "BranchID";
- dropBranch.DataBind();
- dropBranch.SelectedIndex = branchView.Count-1;
- //执行存储过程 cpDep_List
- //返回 "部门表" 数据
- accessDb.SendStoredProcedure("cpDepartment_List");
- depView = accessDb.ReturnDataViewResult();
- depView.AddNew();
- depView[depView.Count-1]["DepName"] = "--选择全部--";
- depView[depView.Count-1]["DepID"] = "0";
- //设置"部门"下拉列表的属性
- dropDep.AutoPostBack = true;
- dropDep.Items.Add(item);
- //"部门"下拉列表和数据源绑定
- dropDep.DataSource = depView;
- dropDep.DataTextField = "DepName";
- dropDep.DataValueField = "DepID";
- dropDep.DataBind();
- dropDep.SelectedIndex = depView.Count-1;
- }
- protected void BindData()
- {
- }
- //执行存储过程cpDepSchByDay_Table1,返回表mrBaseInf人员信息
- //执行存储过程cpDepSchByDay_Table2,返回日程表、预付表信息
- private void returnDataSet()
- {
- accessDb.SendStoredProcedure("cpDepSchByDay_Table1");
- mySet = accessDb.ReturnDataSetResult("empTable");
- accessDb.SendStoredProcedure("cpDepSchByDay_Table2");
- accessDb.SendStoredProcedureParameters("@FDate", SqlDbType.DateTime, date);
- mySet = accessDb.ReturnDataSetResult("schTable");
- }
- //使DataSet中两表empTable和schTable之间建立父子表关系
- private void CreateRelation(string relationName)
- {
- if (true == mySet.Relations.Contains("relationName"))
- return;
-
- DataColumn ParentCol;
- DataColumn ChildCol;
- ParentCol = mySet.Tables["empTable"].Columns["EmpID"];
- ChildCol = mySet.Tables["schTable"].Columns["SchEmpID"];
- DataRelation myRelation = new DataRelation(relationName, ParentCol, ChildCol);
- mySet.Relations.Add(myRelation);
- }
- public void DispScheduleInfo()
- {
- if (pageSize < Convert.ToInt32(dgdData.PageSize))
- {
- rowNum = Convert.ToInt32(dgdData.CurrentPageIndex) * Convert.ToInt32(dgdData.PageSize) + pageSize;
- //string empIDValue = dgdData.Items[pageSize].Cells[1].Text.ToString();
- foreach(DataRow tmpRow in mySet.Tables["empTable"].Rows[rowNum].GetChildRows("EmpID_DepSch"))
- {
- Response.Write ("<a href='haohaoxuexi.aspx?ID=");
- Response.Write (tmpRow["SchID"].ToString());
- Response.Write ("'>");
- Response.Write (tmpRow["Subject"].ToString());
- Response.Write ("</a>");
- Response.Write (rowNum.ToString());
- Response.Write ("<br>");
- }
- pageSize = pageSize + 1;
- }
- }
- private void dgdData_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
- {
- lblHeader.Text = date.ToString("D");
- dgdData.CurrentPageIndex = e.NewPageIndex;
- 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.dropDep.SelectedIndexChanged += new System.EventHandler(this.dropDep_SelectedIndexChanged);
- this.cmdQuery.Click += new System.Web.UI.ImageClickEventHandler(this.cmdQuery_Click);
- this.cmdLastDay.Click += new System.EventHandler(this.cmdLastDay_Click);
- this.cmdNextDay.Click += new System.EventHandler(this.cmdNextDay_Click);
- this.dgdData.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgdData_PageIndexChanged);
- this.dgdData.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.dgdData_SortCommand);
- this.dgdData.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgdData_ItemDataBound);
- this.dgdData.SelectedIndexChanged += new System.EventHandler(this.dgdData_SelectedIndexChanged);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void dgdData_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
- {
- }
- //点击"下一天"
- private void cmdNextDay_Click(object sender, System.EventArgs e)
- {
- date = date.Add(mySpan);
- lblHeader.Text = date.ToString("D");
- ReDate();
- ReDataBind();
- }
- //点击"上一天"
- private void cmdLastDay_Click(object sender, System.EventArgs e)
- {
- date = date.Subtract(mySpan);
- lblHeader.Text = date.ToString("D");
- ReDate();
- ReDataBind();
- }
- private void ReDate()
- {
- dropYear.Text = date.Year.ToString();
- //dropMonth.Items[0]
- dropMonth.SelectedIndex = -1;
- dropMonth.Items[Convert.ToInt32(date.Month)-1].Selected = true;
- dropDay.SelectedIndex = -1;
- dropDay.Items[Convert.ToInt32(date.Day)-1].Selected = true;
- }
- private void ReDataBind()
- {
- dgdData.CurrentPageIndex = 0;
- if (false == search_Flag)
- {
- accessDb.SendStoredProcedure("cpDepSchByDay_Table2");
- accessDb.SendStoredProcedureParameters("@FDate", SqlDbType.DateTime, date);
- mySet = accessDb.ReturnDataSetResult("schTable");
- dgdData.DataBind();
-
- }
- }
- private void dgdData_SelectedIndexChanged(object sender, System.EventArgs e)
- {
-
- }
- private void cmdQuery_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- //临时变量,存放组合查询框值
- //string BranchID;
- //string DepID;
- //string EmpIDName;
- //BranchID = dropBranch.SelectedItem.Value.ToString();
- //DepID = dropDep.SelectedItem.Value.ToString();
- //EmpIDName = dropName.Text;
- //判断各组合查询框的值
- //if("0" == BranchID)
- // BranchID = "%";
- //if("0" == DepID)
- // DepID = "%";
- //if(string.Empty == EmpIDName)
- // EmpIDName = "%";
- //accessDb.SendStoredProcedure("cpDepSchByDay_Search1");
- //accessDb.SendStoredProcedureParameters("@BranchID", SqlDbType.Int, BranchID);
- //accessDb.SendStoredProcedureParameters("@DepID", SqlDbType.Int, DepID);
- //accessDb.SendStoredProcedureParameters("@EmpIDName", SqlDbType.VarChar, EmpIDName);
- //mySet = accessDb.ReturnDataSetResult("schTable");
- }
- private void dropDep_SelectedIndexChanged(object sender, System.EventArgs e)
- {
-
- }
- 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';";
- }
- }
- }
- }