SGGL_SGY/SGGL/FineUIPro.Web/DataShow/CompanyPerson.aspx.cs

127 lines
4.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace FineUIPro.Web.DataShow
{
public partial class CompanyPerson : 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);
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
// 绑定表格t
BindGrid();
this.Panel1.Title = "企业总部/分支机构安全人员(" + BLL.UnitService.GetUnitNameByUnitId(BLL.Const.UnitId_TCC) + "";
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = @"SELECT Person.CompanyBranchPersonId,Unit.UnitName, Person.PersonName,case Person.Sex when '1' then '男' else '女' end as SexStr,Person.IdentityCard,WorkPost.WorkPostName,Person.Telephone,Person.IsOnJob,Person.Remark "
+ @" FROM Person_CompanyBranchPerson AS Person "
+ @" LEFT JOIN Base_Unit AS Unit ON Unit.UnitId=Person.UnitId "
+ @" LEFT JOIN Base_WorkPost AS WorkPost ON Person.WorkPostId=WorkPost.WorkPostId WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
string UnitId = CommonService.GetThisUnitId();
if (this.rbCom.SelectedValue == "0")
{
strSql += " AND Person.UnitId = @UnitId";
listStr.Add(new SqlParameter("@UnitId", UnitId));
}
else
{
strSql += " AND Person.UnitId != @UnitId";
listStr.Add(new SqlParameter("@UnitId", UnitId));
}
if (rbType.SelectedValue == "0")
{
strSql += " AND Person.WorkPostId = @WorkPostId";
listStr.Add(new SqlParameter("@WorkPostId", Const.WorkPost_HSSEDirector));
}
else
{
strSql += " AND WorkPost.IsHsse = 1";
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#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 Grid1_Sort(object sender, GridSortEventArgs 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 Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
}
}