343 lines
12 KiB
C#
343 lines
12 KiB
C#
using BLL;
|
|
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 LaborTeamList : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// 表头过滤
|
|
//FilterDataRowItem = FilterDataRowItemImplement;
|
|
if (!IsPostBack)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
|
|
BLL.SubPackTeamListService.DropSelectUnitWork(drpUnit, this.CurrUser.LoginProjectId, true);
|
|
|
|
BLL.SubPackTeamListService.DropSelectTeamWork(drpBranchTeamList, "-1", this.CurrUser.ProjectId, true);
|
|
|
|
GetButtonPower();
|
|
btnNew.OnClientClick = Window1.GetShowReference("LaborTeamEdit.aspx") + "return false;";
|
|
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 过滤表头
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_FilterChange(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <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 Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
|
|
public void BindGrid()
|
|
{
|
|
DataTable tb = BranchTeamListTeamData();
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
btnMenuModify_Click(null, null);
|
|
}
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 编辑按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuModify_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID.Split(',')[0];
|
|
var item = Funs.DB.SubPack_LaborTeam.FirstOrDefault(p => p.LaborTeamId == id);
|
|
if (item == null)
|
|
{
|
|
Alert.ShowInTop("你要修改的数据在数据库已经不存在了,请重新查询试试!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("LaborTeamEdit.aspx?LaborTeamId={0}", id, "编辑 - ")));
|
|
return;
|
|
|
|
}
|
|
|
|
/// <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 btnMenuBack_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string BlackForeignKey = Grid1.SelectedRowID.Split(',')[0];
|
|
var item = Funs.DB.SubPack_LaborTeam.FirstOrDefault(p => p.LaborTeamId == BlackForeignKey);
|
|
if (item == null)
|
|
{
|
|
Alert.ShowInTop("此操作的数据不存在,请检查!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("SubPackBlackRemark.aspx?BlackForeignKey={0}&IDCard={1}&BlackType={2}&ProjectID={3}", BlackForeignKey, item.CaptainIDCard, Const.SubPackBlackLaborTeam, item.ProjectId)));
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 批量删除
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDel_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID.Split(',')[0];
|
|
|
|
var deleteModel = Funs.DB.SubPack_LaborTeam.FirstOrDefault(p => p.LaborTeamId == id);
|
|
if (deleteModel == null)
|
|
{
|
|
Alert.ShowInTop("选择删除的数据不存在,请检查!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var bzs = Funs.DB.SubPack_BranchTeamListTeam.Where(p => p.LaborTeamId == id);
|
|
if (bzs.Count() > 0)
|
|
{
|
|
Alert.ShowInTop("劳务班组中使用了此劳务队伍,不能删除!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var ps = Funs.DB.SubPack_SubPackPersonnel.Where(p => p.LaborTeamId == id);
|
|
if (ps.Count() > 0)
|
|
{
|
|
Alert.ShowInTop("劳务人员中使用了此劳务队伍,不能删除!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
BLL.SubPackLaborTeamService.DeleteSubPackLaborTeam(id);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, deleteModel.LaborTeamName, id, BLL.Const.SubPackLaborTeamMenuId, "删除劳务队伍记录");
|
|
Grid1.DataBind();
|
|
BindGrid();
|
|
Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 查询按钮事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnQuery_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
protected void btnRset_Click(object sender, EventArgs e)
|
|
{
|
|
drpUnit.SelectedValue = BLL.Const._Null;
|
|
BLL.SubPackTeamListService.DropSelectTeamWork(drpBranchTeamList, drpUnit.SelectedValue, this.CurrUser.LoginProjectId, true);
|
|
drpBranchTeamList.SelectedValue = BLL.Const._Null;
|
|
txtLaborTeamName.Text = string.Empty;
|
|
BindGrid();
|
|
}
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = BLL.CommonService.GetAllButtonList(null, this.CurrUser.UserId, BLL.Const.SubPackLaborTeamMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuModify.Hidden = false;
|
|
//this.btnMenuBack.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDel.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 数据查询
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataTable BranchTeamListTeamData()
|
|
{
|
|
string strSql = @"select a.LaborTeamId,a.ProjectId,a.UnitId,a.BranchTeamListId,a.LaborTeamName,a.Remark,a.SortIndex,isnull(a.State,'0')State,a.CaptainName,a.CaptainIDCard "
|
|
+ @",c.UnitName,b.SubPackTeamListName BranchTeamListName "
|
|
+ @" FROM SubPack_LaborTeam a(NOLOCK) "
|
|
+ @" left join View_SubPack_TeamList b(NOLOCK) on a.BranchTeamListId=b.SubPackTeamListDetailID "
|
|
+ @" left join Base_Unit c(NOLOCK) on a.UnitId=c.UnitId "
|
|
+ @" where a.ProjectId=@ProjectId ";
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
if (drpUnit.SelectedValue != BLL.Const._Null && drpUnit.SelectedValue != null)
|
|
{
|
|
strSql += " AND a.UnitId=@unitId ";
|
|
listStr.Add(new SqlParameter("@unitId", drpUnit.SelectedValue));
|
|
}
|
|
if (drpBranchTeamList.SelectedValue != BLL.Const._Null && drpBranchTeamList.SelectedValue != null)
|
|
{
|
|
strSql += " AND a.BranchTeamListId=@branchTeamListId ";
|
|
listStr.Add(new SqlParameter("@branchTeamListId", drpBranchTeamList.SelectedValue));
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(txtLaborTeamName.Text.Trim()))
|
|
{
|
|
strSql += " AND a.LaborTeamName like '%'+ @LaborTeamName + '%' ";
|
|
listStr.Add(new SqlParameter("@LaborTeamName", txtLaborTeamName.Text.Trim()));
|
|
}
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
return tb;
|
|
}
|
|
/// <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 drpUnit_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BLL.SubPackTeamListService.DropSelectTeamWork(drpBranchTeamList, drpUnit.SelectedValue, this.CurrUser.LoginProjectId, true);
|
|
drpBranchTeamList.SelectedValue = BLL.Const._Null;
|
|
}
|
|
|
|
/// <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 "";
|
|
}
|
|
}
|
|
} |