showdetail.aspx.cs
来自「该管理系统的主要功能是管理员工资料、管理员工考勤、计算员工薪资和业绩评定等。大部」· CS 代码 · 共 844 行 · 第 1/2 页
CS
844 行
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>
/// ShowDetail 的摘要说明。
/// </summary>
public class ShowDetail : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel pnlNextSeason;
protected System.Web.UI.WebControls.Label lblPerformStatusText;
protected System.Web.UI.WebControls.DataGrid grdLast;
protected System.Web.UI.WebControls.TextBox txtSelfComment;
protected System.Web.UI.WebControls.TextBox txtReviewComment;
protected System.Web.UI.WebControls.DropDownList cmbSelfScore;
protected System.Web.UI.WebControls.DropDownList cmbReviewScore;
protected System.Web.UI.WebControls.Button btnSave;
protected System.Web.UI.WebControls.Button btnCheckOver;
protected System.Web.UI.WebControls.Label lblNextObject;
protected System.Web.UI.WebControls.TextBox txtNewObject;
protected System.Web.UI.WebControls.Button btnAdd;
protected System.Web.UI.WebControls.DataGrid grdNext;
protected System.Web.UI.WebControls.Label lblNoLast;
protected System.Web.UI.WebControls.Button btnBackToManage;
protected System.Web.UI.WebControls.Label lblIsManage;
protected System.Web.UI.WebControls.Label lblScore;
protected System.Web.UI.WebControls.Label lblPerformID;
protected System.Web.UI.HtmlControls.HtmlInputButton btnBackToCheck;
protected System.Web.UI.WebControls.Label lblError;
protected System.Web.UI.WebControls.Panel pnlHistoryRecord;
private void Page_Load(object sender, System.EventArgs e)
{
#region// 在此处放置用户代码以初始化页面
if(!this.Page.IsPostBack)
{
this.RebindLastGrd();
this.RebindNextGrd();
}
#endregion
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.grdLast.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.grdLast_ItemCreated);
this.grdLast.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdLast_CancelCommand);
this.grdLast.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdLast_EditCommand);
this.grdLast.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdLast_UpdateCommand);
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
this.btnCheckOver.Click += new System.EventHandler(this.btnCheckOver_Click);
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
this.grdNext.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdNext_CancelCommand);
this.grdNext.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdNext_EditCommand);
this.grdNext.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdNext_UpdateCommand);
this.grdNext.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdNext_DeleteCommand);
this.btnBackToManage.Click += new System.EventHandler(this.btnBackToManage_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
/// <summary>
/// 设定并显示本季度业绩报告所对应的 DataGrid 控件
/// </summary>
private void RebindLastGrd()
{
#region //设定并显示本季度业绩报告所对应的 DataGrid 控件
//获取员工编号信息和员工其他信息
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 )
{
//登录者是经理
this.BindUIofManager();
//保存是经理的标志
this.lblIsManage.Text = "1";
}
else
{
//登录者是一般员工
this.BindUIofEmployee();
//保存是普通员工的标志
this.lblIsManage.Text = "0";
}
}
else
{
//数据库操作失败
this.lblNoLast.Text = "对不起,数据库操作失败,请重试";
this.lblNoLast.Visible = true;
this.pnlHistoryRecord.Visible = false;
this.pnlNextSeason.Visible = false;
}
#endregion
}
/// <summary>
/// 一般员工进入时的页面设置
/// </summary>
private void BindUIofEmployee()
{
//显示"设定下一季度目标"
this.pnlNextSeason.Visible = true;
#region//显示本季度业绩报告
//获取员工编号
int iEmpID = Convert.ToInt32(Session["EmployeeID"]);
//获取当前年份
int iYear = Convert.ToInt32(Request.QueryString["year"]);
//获取当前季度
int iSeason = Convert.ToInt32(Request.QueryString["season"]);
//创建 DataSet 对象,保存查询结果
DataSet dsLastItem = new DataSet();
//获取本季度的业绩报告的具体目标,返回数据库操作是否成功的标志
int iSuccess = DBUtils.Performance.GetPerformItem(iEmpID,iYear,iSeason,ref dsLastItem);
if(iSuccess == (int)DBResult.Success )
{
//数据库操作成功
if(dsLastItem.Tables[0].Rows.Count > 0)
{
//数据库中存在本季度的业绩报告
this.grdLast.DataSource = dsLastItem.Tables[0].DefaultView;
this.grdLast.DataBind();
this.grdLast.Visible = true;
#region//检索数据库,看该报告经理是否已审核结束
//创建一个判断报告是否已经审核结束的标志
bool IsReviewed = false;
iSuccess = DBUtils.Performance.CheckIfReviewed(iEmpID,iYear,iSeason ,ref IsReviewed);
if(IsReviewed)
{
//该报告经理已审核结束
this.lblPerformStatusText.Text = "审核已结束,不可修改";
//数据表格编辑列不可见
this.grdLast.Columns[3].Visible = false;
//员工总评不可用
this.txtSelfComment.Enabled = false;
//员工总评分不可用
this.cmbSelfScore.Enabled = false;
//"保存"不可用
this.btnSave.Enabled = false;
//经理总评,不可用
this.txtReviewComment.Enabled = false;
//经理总评分,不可用
this.cmbReviewScore.Enabled = false;
//"审核结束"不可见
this.btnCheckOver.Visible = false;
//"返回"不可见
this.btnBackToCheck.Visible = false;
}
else
{
//该报告经理还没审核结束
this.lblPerformStatusText.Text = "可修改";
//将只有经理能用的控件设为不可用或不可见
//经理总评,不可用
this.txtReviewComment.Enabled = false;
//经理总评分,不可用
this.cmbReviewScore.Enabled = false;
//"审核结束"不可见
this.btnCheckOver.Visible = false;
//"返回"不可见
this.btnBackToCheck.Visible = false;
}
#endregion
#region//检索数据库,获取该业绩报告的总体信息
//创建 DataSet 对象保存该业绩报告的总体信息
DataSet dsPerform = new DataSet();
//获取该业绩报告的总体信息,返回数据库操作是否成功的标志
iSuccess = DBUtils.Performance.GetPerformance(iEmpID,iYear,iSeason,ref dsPerform);
if(iSuccess == (int)DBResult.Success )
{
//数据库操作成功
if(dsPerform.Tables[0].Rows.Count > 0)
{
if(IsReviewed)
{
//该报告已经审核结束
//获取经理总评
if(dsPerform.Tables[0].Rows[0]["ReviewComment"] != System.DBNull.Value)
{
this.txtReviewComment.Text = dsPerform.Tables[0].Rows[0]["ReviewComment"].ToString();
}
//获取经理总评分
if(dsPerform.Tables[0].Rows[0]["ReviewScore"] != System.DBNull.Value)
{
this.cmbReviewScore.SelectedValue = dsPerform.Tables[0].Rows[0]["ReviewScore"].ToString();
}
//获取员工总评
if(dsPerform.Tables[0].Rows[0]["SelfComment"] != System.DBNull.Value)
{
this.txtReviewComment.Text = dsPerform.Tables[0].Rows[0]["SelfComment"].ToString();
}
//获取员工总评分
if(dsPerform.Tables[0].Rows[0]["SelfScore"] != System.DBNull.Value)
{
this.cmbReviewScore.SelectedValue = dsPerform.Tables[0].Rows[0]["SelfScore"].ToString();
}
}
else
{
//获取经理总评
if(dsPerform.Tables[0].Rows[0]["ReviewComment"] != System.DBNull.Value)
{
this.txtReviewComment.Text = dsPerform.Tables[0].Rows[0]["ReviewComment"].ToString();
}
//获取经理总评分
if(dsPerform.Tables[0].Rows[0]["ReviewScore"] != System.DBNull.Value)
{
this.cmbReviewScore.SelectedValue = dsPerform.Tables[0].Rows[0]["ReviewScore"].ToString();
}
else
{
this.cmbReviewScore.Items.Clear();
}
}
//保存业绩编号
this.lblPerformID.Text = dsPerform.Tables[0].Rows[0]["PerformID"].ToString();
}
else
{
//数据库中没有记录
this.lblNoLast.Text = "没有业务报告的历史记录";
this.lblNoLast.Visible = true;
this.pnlNextSeason.Visible = false;
this.pnlHistoryRecord.Visible = false;
this.cmbReviewScore.Items.Clear();
}
}
else
{
//数据库操作失败
this.lblNoLast.Text = "对不起,数据库操作失败,请重试";
this.lblNoLast.Visible = true;
this.pnlNextSeason.Visible = false;
this.pnlHistoryRecord.Visible = false;
}
#endregion
}
else
{
//数据库中没有本季度的业绩报告
this.lblNoLast.Text = "没有业务报告的历史记录";
this.lblNoLast.Visible = true;
this.pnlNextSeason.Visible = true;
this.pnlHistoryRecord.Visible = false;
}
}
else
{
//数据库操作失败
this.lblNoLast.Text = "对不起,数据库操作失败,请重试";
this.lblNoLast.Visible = true;
this.pnlNextSeason.Visible = false;
this.pnlHistoryRecord.Visible = false;
}
#endregion
}
/// <summary>
/// 部门经理进入时的页面设置
/// </summary>
private void BindUIofManager()
{
//不显示"设定下一季度目标"
this.pnlNextSeason.Visible = false;
#region//显示本季度业绩报告
//获取员工编号
int iEmpID = Convert.ToInt32(Request.QueryString["EmpID"]);
//获取当前年份
int iYear = Convert.ToInt32(Request.QueryString["year"]);
//获取当前季度
int iSeason = Convert.ToInt32(Request.QueryString["season"]);
//创建 DataSet 对象,保存查询结果
DataSet dsLastItem = new DataSet();
//获取本季度的业绩报告的具体目标,返回数据库操作是否成功的标志
int iSuccess = DBUtils.Performance.GetPerformItem(iEmpID,iYear,iSeason,ref dsLastItem);
if(iSuccess == (int)DBResult.Success )
{
//数据库操作成功
if(dsLastItem.Tables[0].Rows.Count > 0)
{
//数据库中存在本季度的业绩报告
this.grdLast.DataSource = dsLastItem.Tables[0].DefaultView;
this.grdLast.DataBind();
this.grdLast.Visible = true;
this.lblNoLast.Visible = false;
#region//检索数据库,看该报告经理是否已审核结束
//创建一个判断报告是否已经审核结束的标志
bool IsReviewed = false;
iSuccess = DBUtils.Performance.CheckIfReviewed(iEmpID,iYear,iSeason ,ref IsReviewed);
if(IsReviewed)
{
//该报告经理已审核结束
this.lblPerformStatusText.Text = "审核已结束,不可修改";
//数据表格编辑列不可见
this.grdLast.Columns[3].Visible = false;
//员工总评不可用
this.txtSelfComment.Enabled = false;
//员工总评分不可用
this.cmbSelfScore.Enabled = false;
//"保存"不可用
this.btnSave.Enabled = false;
//经理总评,不可用
this.txtReviewComment.Enabled = false;
//经理总评分,不可用
this.cmbReviewScore.Enabled = false;
//"审核结束"不可见
this.btnCheckOver.Visible = false;
//"返回"不可见
this.btnBackToCheck.Visible = false;
}
else
{
//该报告经理还没审核结束
this.lblPerformStatusText.Text = "可修改";
//将只有员工可以用的控件设为不可用,或隐藏
//下一季度目标,不可见
this.pnlNextSeason.Visible = false;
//员工总评,不可用
this.txtSelfComment.Enabled = false;
//员工总评分,不可用
this.cmbSelfScore.Enabled = false;
}
#endregion
#region//检索数据库,获取该业绩报告的总体信息
//创建 DataSet 对象保存该业绩报告的总体信息
DataSet dsPerform = new DataSet();
//获取该业绩报告的总体信息,返回数据库操作是否成功的标志
iSuccess = DBUtils.Performance.GetPerformance(iEmpID,iYear,iSeason,ref dsPerform);
if(iSuccess == (int)DBResult.Success )
{
//数据库操作成功
if(dsPerform.Tables[0].Rows.Count > 0)
{
if(IsReviewed)
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?