127 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			127 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| 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();
 | ||
|                 // 绑定表格
 | ||
|                 BindGrid();
 | ||
|                 this.Panel1.Title = "企业总部/分支机构安全人员(" + BLL.UnitService.GetUnitNameByUnitId(BLL.Const.UnitId_CWCEC) + ")";
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <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 = BLL.Const.UnitId_CWCEC;
 | ||
|             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
 | ||
|     }
 | ||
| } |