618 lines
22 KiB
C#
618 lines
22 KiB
C#
using BLL;
|
|
using FineUIPro.Web.DataShow;
|
|
using FineUIPro.Web.ProjectData;
|
|
using Model;
|
|
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.SubPackManage
|
|
{
|
|
public partial class SubPackPersonnelRegistration : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 项目id
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 行主键
|
|
/// </summary>
|
|
public string SubPackPersonnelID
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["SubPackPersonnelID"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["SubPackPersonnelID"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
}
|
|
|
|
|
|
BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, "-1", "-1", "-1", this.ProjectId, true);
|
|
drpTeam.SelectedValue = BLL.Const._Null;
|
|
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
this.btnMenuDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请至少选择一项!");
|
|
this.btnMenuDelete.ConfirmText = String.Format("你确定要删除选中的 <b><script>{0}</script></b> 行数据吗?", Grid1.GetSelectedCountReference());
|
|
this.InitTreeMenu();
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvProjectAndUnit.Nodes.Clear();
|
|
var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId);
|
|
if (project != null)
|
|
{
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode = new TreeNode
|
|
{
|
|
Text = project.ProjectName,
|
|
NodeID = project.ProjectId
|
|
};
|
|
rootNode.Expanded = true;
|
|
this.tvProjectAndUnit.Nodes.Add(rootNode);
|
|
GetUnitLists(rootNode.Nodes, this.ProjectId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载单位
|
|
/// </summary>
|
|
/// <param name="nodes"></param>
|
|
/// <param name="parentId"></param>
|
|
private void GetUnitLists(TreeNodeCollection nodes, string parentId)
|
|
{
|
|
|
|
var unitWorkList = (from x in BLL.Funs.DB.Base_Unit
|
|
join y in BLL.Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
|
|
where y.UnitType == "2" && y.ProjectId == parentId
|
|
select new
|
|
{
|
|
UnitName = x.UnitName,
|
|
UnitId = x.UnitId,
|
|
}).ToList();
|
|
|
|
TreeNode newNode = null;
|
|
foreach (var q in unitWorkList)
|
|
{
|
|
newNode = new TreeNode
|
|
{
|
|
Text = q.UnitName,
|
|
NodeID = q.UnitId + "|" + parentId,
|
|
ToolTip = "分包商"
|
|
};
|
|
|
|
newNode.EnableClickEvent = true;
|
|
nodes.Add(newNode);
|
|
GetBranchTeamList(newNode.Nodes, q.UnitId, parentId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载劳务公司
|
|
/// </summary>
|
|
/// <param name="nodes"></param>
|
|
/// <param name="parentId"></param>
|
|
private void GetBranchTeamList(TreeNodeCollection nodes, string unitId, string parentId)
|
|
{
|
|
|
|
var branchTeamList = (from x in BLL.Funs.DB.View_SubPack_TeamList
|
|
where x.UnitWorkId == unitId
|
|
select new
|
|
{
|
|
BranchTeamListId = x.SubPackTeamListDetailID,
|
|
BranchTeamListName = x.SubPackTeamListName,
|
|
}).Distinct().ToList();
|
|
|
|
TreeNode newNode = null;
|
|
foreach (var itme in branchTeamList)
|
|
{
|
|
newNode = new TreeNode
|
|
{
|
|
Text = itme.BranchTeamListName,
|
|
NodeID = itme.BranchTeamListId + "|" + unitId + "|" + parentId,
|
|
ToolTip = "劳务公司"
|
|
};
|
|
|
|
newNode.EnableClickEvent = true;
|
|
nodes.Add(newNode);
|
|
GetLaborTeam(newNode.Nodes, unitId, itme.BranchTeamListId, parentId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载劳务队伍
|
|
/// </summary>
|
|
/// <param name="nodes"></param>
|
|
/// <param name="parentId"></param>
|
|
private void GetLaborTeam(TreeNodeCollection nodes, string unitId, string branchTeamListId, string parentId)
|
|
{
|
|
|
|
var branchTeamList = (from x in BLL.Funs.DB.SubPack_LaborTeam
|
|
where x.BranchTeamListId == branchTeamListId
|
|
select new
|
|
{
|
|
LaborTeamId = x.LaborTeamId,
|
|
LaborTeamName = x.LaborTeamName,
|
|
}).Distinct().ToList();
|
|
|
|
TreeNode newNode = null;
|
|
foreach (var itme in branchTeamList)
|
|
{
|
|
newNode = new TreeNode
|
|
{
|
|
Text = itme.LaborTeamName,
|
|
NodeID = itme.LaborTeamId + "|" + branchTeamListId + "|" + unitId + "|" + parentId,
|
|
ToolTip = "劳务队伍"
|
|
};
|
|
|
|
newNode.EnableClickEvent = true;
|
|
nodes.Add(newNode);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
if (this.tvProjectAndUnit != null && !string.IsNullOrEmpty(this.tvProjectAndUnit.SelectedNodeID))
|
|
{
|
|
string id = this.tvProjectAndUnit.SelectedNodeID;
|
|
string unitId = string.Empty;
|
|
string teamListId = string.Empty;
|
|
string laborTeamId = string.Empty;
|
|
var str = id.Split('|');
|
|
if (str.Count() == 2)
|
|
{
|
|
unitId = str[0];
|
|
}
|
|
if (str.Count() == 3)
|
|
{
|
|
teamListId = str[0];
|
|
unitId = str[1];
|
|
}
|
|
if (str.Count() == 4)
|
|
{
|
|
laborTeamId = str[0];
|
|
teamListId = str[1];
|
|
unitId = str[2];
|
|
}
|
|
|
|
string strSql = @"select a.SubPackPersonnelID,a.ProjectId,a.UnitId,a.PersonName,a.IdentityCard,a.Remark "
|
|
+ @",b.UnitName,c.SubPackTeamListName BranchTeamListName,d.BranchTeamListTeamName,isnull(a.State,'0') State,e.LaborTeamName "
|
|
+ @" INTO #tempSubPack_Personne from SubPack_SubPackPersonnel a "
|
|
+ @" left join Base_Unit b(NOLOCK) on a.UnitId=b.UnitId "
|
|
+ @" left join View_SubPack_TeamList c(NOLOCK) on a.BranchTeamListId=c.SubPackTeamListDetailID "
|
|
+ @" left join SubPack_BranchTeamListTeam d(NOLOCK) on a.BranchTeamListTeamId=d.BranchTeamListTeamId "
|
|
+ @" left join SubPack_LaborTeam e(NOLOCK) on a.LaborTeamId=e.LaborTeamId "
|
|
+ @" Where a.ProjectId=@ProjectId ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>
|
|
{
|
|
new SqlParameter("@ProjectId", this.ProjectId)
|
|
};
|
|
if (!string.IsNullOrEmpty(unitId) && unitId != "0")
|
|
{
|
|
strSql += " AND a.UnitId =@UnitId ";
|
|
listStr.Add(new SqlParameter("@UnitId", unitId));
|
|
}
|
|
else
|
|
{
|
|
strSql += " AND a.UnitId IS NULL";
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtPersonName.Text.Trim()))
|
|
{
|
|
strSql += " AND a.PersonName LIKE @PersonName ";
|
|
listStr.Add(new SqlParameter("@PersonName", "%" + this.txtPersonName.Text.Trim() + "%"));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.txtIdentityCard.Text.Trim()))
|
|
{
|
|
strSql += " AND a.IdentityCard LIKE @IdentityCard ";
|
|
listStr.Add(new SqlParameter("@IdentityCard", "%" + this.txtIdentityCard.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(teamListId))
|
|
{
|
|
strSql += " AND a.BranchTeamListId=@branchTeamListId ";
|
|
listStr.Add(new SqlParameter("@branchTeamListId", teamListId));
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(laborTeamId))
|
|
{
|
|
strSql += " AND a.LaborTeamId=@LaborTeamId ";
|
|
listStr.Add(new SqlParameter("@LaborTeamId", laborTeamId));
|
|
}
|
|
if (drpTeam.SelectedValue != BLL.Const._Null && drpTeam.SelectedValue != null)
|
|
{
|
|
strSql += " AND a.BranchTeamListTeamId=@branchTeamListTeamId ";
|
|
listStr.Add(new SqlParameter("@branchTeamListTeamId", drpTeam.SelectedValue));
|
|
}
|
|
|
|
strSql += " SELECT * FROM #tempSubPack_Personne ";
|
|
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();
|
|
}
|
|
}
|
|
|
|
#region 关闭弹出窗口
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
/// <summary>
|
|
/// 关闭导入弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window3_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvProjectAndUnit_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
string id = this.tvProjectAndUnit.SelectedNodeID;
|
|
var str = id.Split('|');
|
|
if (str.Count() == 1)
|
|
{
|
|
BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, "-1", "-1", "-1", this.ProjectId, true);
|
|
drpTeam.SelectedValue = BLL.Const._Null;
|
|
}
|
|
if (str.Count() == 2)
|
|
{
|
|
BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, str[0], null, null, this.ProjectId, true);
|
|
drpTeam.SelectedValue = BLL.Const._Null;
|
|
}
|
|
if (str.Count() == 3)
|
|
{
|
|
BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, str[1], str[0], null, this.ProjectId, true);
|
|
drpTeam.SelectedValue = BLL.Const._Null;
|
|
}
|
|
if (str.Count() == 4)
|
|
{
|
|
BLL.SubPackSubPackPersonnelService.DropSelectTeam(drpTeam, str[2], str[1], str[0], this.ProjectId, true);
|
|
drpTeam.SelectedValue = BLL.Const._Null;
|
|
}
|
|
|
|
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 右键编辑事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.ViewData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键加入黑名单事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuBack_Click(object sender, EventArgs e)
|
|
{
|
|
this.BackData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
this.DeleteData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加入黑名单
|
|
/// </summary>
|
|
private void BackData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string BlackForeignKey = Grid1.SelectedRowID.Split(',')[0];
|
|
var item = Funs.DB.SubPack_SubPackPersonnel.FirstOrDefault(p => p.SubPackPersonnelID == BlackForeignKey);
|
|
if (item == null)
|
|
{
|
|
Alert.ShowInTop("此操作的数据不存在,请检查!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("SubPackBlackRemark.aspx?BlackForeignKey={0}&IDCard={1}&BlackType={2}&ProjectID={3}", BlackForeignKey, item.IdentityCard, Const.SubPackBlackListPersonnel, item.ProjectId)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除方法
|
|
/// </summary>
|
|
private void DeleteData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var getV = BLL.Funs.DB.SubPack_SubPackPersonnel.FirstOrDefault(p => p.SubPackPersonnelID == rowID);
|
|
if (getV != null)
|
|
{
|
|
BLL.LogService.AddSys_Log(this.CurrUser, getV.PersonName, getV.SubPackPersonnelID, BLL.Const.SubPackPersonnelRegistrationMenuId, BLL.Const.BtnDelete);
|
|
BLL.SubPackSubPackPersonnelService.DeleteSubPackSubPackPersonnel(rowID);
|
|
}
|
|
}
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!(表格数据已重新绑定)", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// Grid双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
this.ViewData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑
|
|
/// </summary>
|
|
private void ViewData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
this.SubPackPersonnelID = Grid1.SelectedRowID;
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("SubPackPersonnelRegistrationEdit.aspx?SubPackPersonnelID={0}", this.SubPackPersonnelID, "编辑 - ")));
|
|
}
|
|
|
|
#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="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.tvProjectAndUnit.SelectedNodeID.Contains("|"))
|
|
{
|
|
string id = this.tvProjectAndUnit.SelectedNodeID;
|
|
string[] str = id.Split('|');
|
|
string unitWorkId = string.Empty;
|
|
string projectId = string.Empty;
|
|
string teamListId = string.Empty;
|
|
string laborTeamId = string.Empty;
|
|
if (str.Count() > 1)
|
|
{
|
|
if (str.Count() == 2)
|
|
{
|
|
unitWorkId = id.Split('|')[0];
|
|
projectId = id.Split('|')[1];
|
|
}
|
|
if (str.Count() == 3)
|
|
{
|
|
teamListId = id.Split('|')[0];
|
|
unitWorkId = id.Split('|')[1];
|
|
projectId = id.Split('|')[2];
|
|
}
|
|
if (str.Count() == 4)
|
|
{
|
|
laborTeamId = id.Split('|')[0];
|
|
teamListId = id.Split('|')[1];
|
|
unitWorkId = id.Split('|')[2];
|
|
projectId = id.Split('|')[3];
|
|
}
|
|
|
|
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("SubPackPersonnelRegistrationEdit.aspx?ProjectId={0}&&UnitWorkId={1}&teamListId={2}&laborTeamId={3}", projectId, unitWorkId, teamListId, laborTeamId, "选择 - ")));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择单位!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 分页选择下拉改变事件
|
|
/// <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();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
Grid1.SortDirection = e.SortDirection;
|
|
Grid1.SortField = e.SortField;
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 判断按钮权限
|
|
/// <summary>
|
|
/// 判断按钮权限
|
|
/// </summary>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.SubPackPersonnelRegistrationMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
this.btnImport.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDelete.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnMenuEdit.Hidden = false;
|
|
}
|
|
}
|
|
//有劳务人员黑名单修改权限
|
|
var buttonBaseList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.SubPackBlacklistMenuId);
|
|
if (buttonBaseList.Count() > 0)
|
|
{
|
|
if (buttonBaseList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
//this.btnMenuBack.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 把状态转换代号为文字形式
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertState(object state)
|
|
{
|
|
if (state != null)
|
|
{
|
|
if (state.ToString() == "0")
|
|
{
|
|
return "正常";
|
|
}
|
|
else if (state.ToString() == "1")
|
|
{
|
|
return "黑名单";
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导入按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnImport_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SubPackPersonnelRegistrationIn.aspx", "导入 - ")));
|
|
}
|
|
}
|
|
} |