213 lines
7.1 KiB
C#
213 lines
7.1 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.Person
|
|
{
|
|
public partial class PersonTraining : PageBase
|
|
{
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("PersonTrainingAdd.aspx") + "return false;";
|
|
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
|
{
|
|
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
|
}
|
|
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"select TrainingPlanId, TrainingPlanCode, TrainingPlanTitle, TrainingPlanContent, StartTime, EndTime, CompilePersonId, Compile.UserName,CompileTime,(case when State='0' then '待'+Compile.UserName+'提交' when State='1' then '待'+Approve.UserName+'审核' when State='2' then '已完成' end) State from Person_TrainingPlan T left join Sys_User Compile on T.CompilePersonId=Compile.UserId left join Sys_User Approve on T.ApprovePersonId=Approve.UserId";
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
//tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.PersonTrainingMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuEdit.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDelete.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除数据
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
this.DeleteData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除方法
|
|
/// </summary>
|
|
private void DeleteData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
string strShowNotify = string.Empty;
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var PersonDuty = BLL.Person_TrainingPlanService.GetPersonTrainingPlanById(rowID);
|
|
if (PersonDuty != null)
|
|
{
|
|
BLL.Person_TrainingPlanService.DeletePersonTrainingPlan(rowID);
|
|
}
|
|
}
|
|
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 分页
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页显示条数下拉框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region Grid操作
|
|
|
|
protected void MenuView_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../Person/PersonTrainingView.aspx?TrainingPlanId={0}", Grid1.SelectedRowID, "操作 - ")));
|
|
}
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键编辑事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string Id = Grid1.SelectedRowID;
|
|
string url = "PersonTrainingView.aspx?TrainingPlanId={0}";
|
|
var TrainingPlan = BLL.Person_TrainingPlanService.GetPersonTrainingPlanById(Id);
|
|
if (TrainingPlan.State == "0" && TrainingPlan.CompilePersonId==this.CurrUser.UserId)
|
|
{
|
|
url = "PersonTrainingAdd.aspx?TrainingPlanId={0}";
|
|
}
|
|
else if (TrainingPlan.State == "1" && TrainingPlan.ApprovePersonId == this.CurrUser.UserId)
|
|
{
|
|
url = "PersonTrainingEdit.aspx?TrainingPlanId={0}";
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format(url, Id, "操作 - ")));
|
|
}
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |