checkperform.aspx.cs
来自「该管理系统的主要功能是管理员工资料、管理员工考勤、计算员工薪资和业绩评定等。大部」· CS 代码 · 共 298 行
CS
298 行
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.Performance
{
/// <summary>
/// CheckPerform 的摘要说明。
/// </summary>
public class CheckPerform : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblYear;
protected System.Web.UI.WebControls.Label lblReason;
protected System.Web.UI.WebControls.Button btnPrev;
protected System.Web.UI.WebControls.Button btnNext;
protected System.Web.UI.WebControls.DataGrid grdResult;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.Panel pnlRecord;
protected System.Web.UI.WebControls.Label lblDeptID;
private void Page_Load(object sender, System.EventArgs e)
{
#region// 在此处放置用户代码以初始化页面
if(!this.Page.IsPostBack)
{
//获取员工编号信息和员工其他信息
int iEmpID = Convert.ToInt32(Session["EmployeeID"]);
Employee employee = new Employee();
//查询员工信息,并返回查询是否成功
int iSuccess = Employee.GetEmployeeInfo(iEmpID,ref employee);
if(iSuccess == (int)DBResult.Success)
{
//数据库操作成功
//判断当前登录者是否有权限查看此页
if(employee.IsManager )
{
//登录者是经理,可以查看此网
//判断是否为总经理,总经理没有要查看的内容
int iCEOID = 0;
iSuccess = Employee.GetCEOInfo(ref iCEOID);
if(iSuccess ==(int)DBResult.Success)
{
//查询是否为总经理操作成功
if(employee.EmployeeID == iCEOID)
{
//当前用户是总经理,没有要查看的内容
this.lblMessage.Text = "对不起,没有您要查看的内容";
this.lblMessage.Visible = true;
this.pnlRecord.Visible = false;
}
else
{
//当前员工是部门经理,可以查看本部门的季度业绩记录
this.pnlRecord.Visible = true;
//绑定数据,设置页面
//保存部门经理所在的部门编号
this.lblDeptID.Text = employee.DeptID.ToString();
this.lblDeptID.Visible = false;
//年份
this.lblYear.Text = System.DateTime.Now.Year.ToString();
#region//季度
int iSeason = 1;
switch(System.DateTime.Now.Month )
{
case 1:
case 2:
case 3:
iSeason = 1;
break;
case 4:
case 5:
case 6:
iSeason = 2;
break;
case 7:
case 8:
case 9:
iSeason = 3;
break;
case 10:
case 11:
case 12:
iSeason = 4;
break;
default:
iSeason = 1;
break;
}
this.lblReason.Text = iSeason.ToString();
#endregion
this.RefreshPage();
}
}
else
{
//查询是否为总经理操作失败
this.lblMessage.Text = "数据库操作失败,请重试";
this.lblMessage.Visible = true;
this.pnlRecord.Visible = false;
}
}
else
{
//登录者是一般员工,不可查看此网页
this.lblMessage.Text = "对不起,该网页属经理专用,请退出!";
this.lblMessage.Visible = true;
this.pnlRecord.Visible = false;
}
}
else
{
//数据库操作失败
this.lblMessage.Text = "对不起,数据库操作失败,请重试";
this.lblMessage.Visible = true;
this.pnlRecord.Visible = false;
}
}
#endregion
}
/// <summary>
/// 网页中的年份和季度等信息,设置界面控件的显示内容和方式
/// </summary>
private void RefreshPage()
{
//调用 Performance.GetSubmittedPerform(iDeptID, iYear, iSeason, dsResult) 函数,从数据库中获取该部门该季度的业绩汇总信息。
//获取要查询的部门编号
int iDeptID = Convert.ToInt32(this.lblDeptID.Text.Trim());
//获取要查询的年份
int iYear = Convert.ToInt32(this.lblYear.Text.Trim());
//获取要查询的季度
int iSeason = Convert.ToInt32(this.lblReason.Text.Trim());
//创建 DataSet 对象,保存查询结果
DataSet dsResult = new DataSet();
//执行数据查询操作,返回数据库操作是否成功的标志
int iSuccess = DBUtils.Performance.GetSubmittedPerform(iDeptID,iYear,iSeason,ref dsResult);
if(iSuccess == (int)DBResult.Success )
{
//数据库操作成功
if(dsResult.Tables[0].Rows.Count > 0)
{
//数据库中有要查询的记录
//绑定数据
this.grdResult.DataSource = dsResult.Tables[0].DefaultView;
this.grdResult.DataBind();
//将记录显示出来
this.grdResult.Visible = true;
this.lblMessage.Visible = false;
}
else
{
//数据库中没有记录
this.lblMessage.Text = "没有您要查询的任何记录";
this.lblMessage.Visible = true;
this.grdResult.Visible = false;
}
}
else
{
//数据库操作失败
this.lblMessage.Text = "对不起,数据库操作失败,请重试";
this.lblMessage.Visible = true;
this.grdResult.Visible = false;
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnPrev.Click += new System.EventHandler(this.btnPrev_Click);
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
this.grdResult.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdResult_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnNext_Click(object sender, System.EventArgs e)
{
//获取当前年份
int iYear = Convert.ToInt32(this.lblYear.Text.Trim());
//获取当前季度
int iSeason = Convert.ToInt32(this.lblReason.Text.Trim());
if(iSeason == 4)
{
//当前是第四季度,下一季度为下一年的第一季度
iYear = iYear + 1;
iSeason = 1;
}
else
{
iSeason = iSeason + 1;
}
//重新设置当前季度
this.lblReason.Text = iSeason.ToString();
//重新设置当前年份
this.lblYear.Text = iYear.ToString();
//刷新页面数据
this.RefreshPage();
}
private void btnPrev_Click(object sender, System.EventArgs e)
{
//获取当前年份
int iYear = Convert.ToInt32(this.lblYear.Text.Trim());
//获取当前季度
int iSeason = Convert.ToInt32(this.lblReason.Text.Trim());
if(iSeason == 1)
{
//当前是第一季度,上一季度为上一年的第四季度
iYear = iYear - 1;
iSeason = 4;
}
else
{
iSeason = iSeason - 1;
}
//重新设置当前季度
this.lblReason.Text = iSeason.ToString();
//重新设置当前年份
this.lblYear.Text = iYear.ToString();
//刷新页面数据
this.RefreshPage();
}
private void grdResult_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//单击"审核",网页跳转到业绩报告详细页面上去
if(e.CommandName == "Select")
{
//获取员工编号
int iEmpID = Convert.ToInt32(e.Item.Cells[0].Text.Trim());
//获取当前年份
int iYear = Convert.ToInt32(this.lblYear.Text.Trim());
//获取当前季度
int iSeason = Convert.ToInt32(this.lblReason.Text.Trim());
//转向业绩报告详细页面
Response.Redirect("ShowDetail.aspx?year=" + iYear + "&season=" + iSeason + "&EmpID=" + iEmpID);
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?