SGGL_SHJ/SGGL/FineUIPro.Web/Person/DepartPerson.aspx.cs

260 lines
9.4 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.Person
{
public partial class DepartPerson : PageBase
{
/// <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("PersonEdit.aspx?UnitId=" + Const.UnitId_SEDIN + "&DepartId=" + Const.Depart_constructionId) + "return false;";
ProjectService.InitProjectShortNameDropDownList(this.drpProject, false);
Funs.FineUIPleaseSelect(drpProject, "按项目查询");
DropListService.InitConstDropDownList(this.drpIsPost, DropListService.Group_IsPost, true);
this.drpIsPost.SelectedValue = Const._True;
DropListService.InitConstDropDownList(this.drpPersonType, DropListService.Group_PersonType, false);
Funs.FineUIPleaseSelect(drpPersonType, "按员工类别查询");
// 绑定表格
this.BindGrid();
}
else
{
string arg = GetRequestEventArgument(); // 此函数所在文件PageBase.cs
string[] args = arg.Split('$');
string personId = Grid1.SelectedRowID;
if (args.Length > 0 && !string.IsNullOrEmpty(personId))
{
var commandName = args[0];
if (commandName == "editit")
{
if (!this.btnMenuEdit.Hidden)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonEdit.aspx?PersonId={0}&UnitId={1}&DepartId={2}", personId, Const.sedinId, Const.Depart_constructionId, "编辑 - ")));
}
else
{
ShowNotify("您没有权限!", MessageBoxIcon.Warning);
}
}
else if (commandName == "details")
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonView.aspx?PersonId={0}", personId, "查看 - ")));
}
else if (commandName == "reset")
{
if (!this.btnMenuEdit.Hidden)
{
BLL.Person_PersonsService.UpdatePassword(personId, BLL.Const.Password);
ShowNotify("密码已重置为原始密码!", MessageBoxIcon.Success);
}
else
{
ShowNotify("您没有权限!", MessageBoxIcon.Warning);
}
}
else if (commandName == "salary")
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonView.aspx?PersonId={0}", Grid1.SelectedRowID, "查看 - ")));
}
}
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
var getData = Person_PersonsService.getListData(Const.UnitId_SEDIN, Const.Depart_constructionId, this.drpProject.SelectedValue,
this.txtPersonName.Text.Trim(), this.txtIdCard.Text.Trim(), this.drpIsPost.SelectedValue, this.drpPersonType.SelectedValue, Grid1);
Grid1.RecordCount = Person_PersonsService.count;
Grid1.DataSource = getData;
Grid1.DataBind();
}
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btSearch_Click(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.DepartPersonMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
this.btnImport.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 = Person_PersonsService.DeletePersons(Grid1.SelectedRowIDArray, this.CurrUser);
BindGrid();
if (!string.IsNullOrEmpty(strShowNotify))
{
Alert.ShowInTop(strShowNotify, MessageBoxIcon.Warning);
}
else
{
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
/// <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;
}
if (this.btnMenuEdit.Hidden)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonView.aspx?PersonId={0}", Grid1.SelectedRowID, "查看 - ")));
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonEdit.aspx?PersonId={0}&UnitId={1}&DepartId={2}", Grid1.SelectedRowID, Const.sedinId, Const.Depart_constructionId, "编辑 - ")));
}
}
#region
/// <summary>
/// 导入按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("UserIn.aspx", "导入 - ")));
}
#endregion
#region
/// <summary>
/// 查看人员详细信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSee_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInParent("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PersonView.aspx?PersonId={0}", Grid1.SelectedRowID, "查看 - ")));
}
#endregion
}
}