352 lines
12 KiB
C#
352 lines
12 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.ZHGL.Person
|
|
{
|
|
public partial class BranchPerson : 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);
|
|
BLL.UnitService.InitNoThisAllUnitDownList(this.drpUnit, false);
|
|
Funs.FineUIPleaseSelect(drpUnit, "按单位查询");
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
if (this.CurrUser.UnitId != null && thisUnit != null && this.CurrUser.UnitId != thisUnit.UnitId)
|
|
{
|
|
this.drpUnit.Enabled = false;
|
|
this.drpUnit.SelectedValue = this.CurrUser.UnitId;
|
|
}
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("BranchPersonEdit.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 CompanyBranchPerson.CompanyBranchPersonId,CompanyBranchPerson.UnitId,Unit.UnitName,CompanyBranchPerson.PersonName,case CompanyBranchPerson.Sex when '1' then '男' else '女' end as SexStr,CompanyBranchPerson.IdentityCard,WorkPost.WorkPostName,CompanyBranchPerson.Telephone,CompanyBranchPerson.IsOnJob,CompanyBranchPerson.Remark "
|
|
+ @" FROM Person_CompanyBranchPerson AS CompanyBranchPerson "
|
|
+ @" LEFT JOIN Base_Unit AS Unit ON CompanyBranchPerson.UnitId=Unit.UnitId"
|
|
+ @" LEFT JOIN Base_WorkPost AS WorkPost ON CompanyBranchPerson.WorkPostId=WorkPost.WorkPostId WHERE 1=1 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND CompanyBranchPerson.UnitId = @UnitId";
|
|
listStr.Add(new SqlParameter("@UnitId", this.drpUnit.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtPersonName.Text.Trim()))
|
|
{
|
|
strSql += " AND PersonName LIKE @PersonName";
|
|
listStr.Add(new SqlParameter("@PersonName", "%" + this.txtPersonName.Text.Trim() + "%"));
|
|
}
|
|
var thisUnit = CommonService.GetIsThisUnit();
|
|
if (thisUnit != null)
|
|
{
|
|
strSql += " AND CompanyBranchPerson.UnitId != @UnitId2";
|
|
listStr.Add(new SqlParameter("@UnitId2", thisUnit.UnitId));
|
|
}
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#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_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.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var person = BLL.CompanyBranchPersonService.GetCompanyBranchPersonById(id);
|
|
if (person != null)
|
|
{
|
|
if (this.btnMenuEdit.Hidden) ////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("BranchPersonView.aspx?CompanyBranchPersonId={0}", id, "查看 - ")));
|
|
}
|
|
else
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("BranchPersonEdit.aspx?CompanyBranchPersonId={0}", id, "编辑 - ")));
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 授权
|
|
/// <summary>
|
|
/// 右键授权事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuUpdate_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var person = BLL.CompanyBranchPersonService.GetCompanyBranchPersonById(id);
|
|
if (person != null)
|
|
{
|
|
var user = BLL.UserService.GetUserByIdentityCard(person.IdentityCard);
|
|
if (user == null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../../SysManage/UserListEdit.aspx?CompanyBranchPersonId={0}", id, "授权 - ")));
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("该人员已授权!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var meet = BLL.CompanyBranchPersonService.GetCompanyBranchPersonById(rowID);
|
|
if (meet != null)
|
|
{
|
|
BLL.LogService.AddSys_Log(this.CurrUser, meet.PersonName, meet.CompanyBranchPersonId, BLL.Const.BranchPersonMenuId, BLL.Const.BtnDelete);
|
|
|
|
BLL.CompanyBranchPersonService.DeleteCompanyBranchPersonById(rowID);
|
|
}
|
|
}
|
|
|
|
this.BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 格式化字符串
|
|
/// <summary>
|
|
/// 获取整理人姓名
|
|
/// </summary>
|
|
/// <param name="compileMan"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertCompileMan(object userId)
|
|
{
|
|
string userName = string.Empty;
|
|
if (userId != null)
|
|
{
|
|
var user = BLL.UserService.GetUserByUserId(userId.ToString());
|
|
if (user != null)
|
|
{
|
|
userName = user.UserName;
|
|
}
|
|
}
|
|
return userName;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.BranchPersonMenuId);
|
|
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.BtnSave))
|
|
{
|
|
this.btnMenuUpdate.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 btnImport_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("BranchPersonIn.aspx", "导入 - ")));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭导入弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
Response.ClearContent();
|
|
string filename = Funs.GetNewFileName();
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("分支机构人员" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
Response.ContentType = "application/excel";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
this.Grid1.PageSize = this.Grid1.RecordCount;
|
|
this.BindGrid();
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btSearch_Click(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
}
|
|
} |