📄 showattenddetail.aspx.cs
字号:
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 DBUtils;
namespace BlueHill.Attendance
{
/// <summary>
/// ShowAttendDetail 的摘要说明。
/// </summary>
public class ShowAttendDetail : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid grdResult;
protected System.Web.UI.WebControls.Button btnBack;
protected System.Web.UI.WebControls.Label lblName;
protected System.Web.UI.WebControls.Label lblStartTime;
protected System.Web.UI.WebControls.Label lblEndTime;
protected System.Web.UI.WebControls.Label lblMessage;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!this.Page.IsPostBack )
{
try
{
//获取员工编号
int iEmpID = Convert.ToInt32( Request.QueryString["EmpID"]);
//获取员工姓名
string strName = Request.QueryString["Name"].ToString();
this.lblName.Text = strName;
//获取开始时间
string strStartTime = Request.QueryString["StartTime"].ToString();
this.lblStartTime.Text = strStartTime;
//获取结束时间
string strEndTime = Request.QueryString["EndTime"].ToString();
this.lblEndTime.Text = strEndTime;
//创建 DataSet 对象,保存查询结果
DataSet dsResult = new DataSet();
//查询该员工在该时间段的考勤信息,返回数据库操作是否正确标志
int iSuccess = DBUtils.Attendance.QueryIndividual(iEmpID,strStartTime,strEndTime,ref dsResult);
if(iSuccess == (int)DBResult.Success )
{
//数据库操作成功
if(dsResult.Tables[0].Rows.Count >0 )
{
//该员工在该时间段有考勤信息
//显示考勤列表
this.grdResult.Visible = true;
this.lblMessage.Visible = false;
//绑定考勤信息到 DataGrid 对象
this.grdResult.DataSource = dsResult.Tables[0].DefaultView;
this.grdResult.DataBind();
}
else
{
//该员工在该时间段没有考勤信息
this.lblMessage.Text = "全部考勤合格";
this.lblMessage.Visible = true;
this.grdResult.Visible = false;
}
}
else
{
//数据库操作失败
this.lblMessage.Text = "数据库操作失败,请重试";
this.lblMessage.Visible = true;
this.grdResult.Visible = false;
}
}
catch(Exception ex)
{
//数据传递失败
Response.Write("<script>alert('数据传递失败')</script>");
//返回部门汇总页面
Response.Redirect(Request.UrlReferrer.ToString());
}
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnBack_Click(object sender, System.EventArgs e)
{
//后退到 Summary.aspx 页面
Response.Redirect("Summary.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -