xinjiang/SGGL/FineUIPro.Web/SubPackManage/SubPackBlackLaborTeam.aspx.cs

266 lines
9.3 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;
using System.Windows.Forms;
namespace FineUIPro.Web.SubPackManage
{
public partial class SubPackBlackLaborTeam : 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);
// 绑定表格
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>
/// 分页显示条数下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
#region
/// <summary>
/// 加入黑名单按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuLaborTeamBack_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(Window1.GetShowReference(String.Format("SubPackBlackRemark.aspx?BlackForeignKey={0}&IDCard={1}&BlackType={2}&ProjectID={3}", BlackForeignKey, item.CaptainIDCard, Const.SubPackBlackLaborTeam, item.ProjectId)));
}
/// <summary>
/// 加入黑名单按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuNoLaborTeamBack_Click(object sender, EventArgs e)
{
var buttonList = BLL.CommonService.GetAllButtonList(null, this.CurrUser.UserId, BLL.Const.SubPackBlacklistLaborTeamMenuId);
if (buttonList.Count <= 0 || !buttonList.Contains(BLL.Const.BtnModify))
{
Alert.ShowInTop("没有操作此功能权限!", MessageBoxIcon.Warning);
return;
}
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;
}
if (item.State == "0")
{
Alert.ShowInTop("此劳务队伍已经解除黑名单,请不要重复操作!", MessageBoxIcon.Warning);
return;
}
BLL.SubPackBlacklistService.DeleteBackLaborTeam(item.LaborTeamId);
BindGrid();
ShowNotify("解除黑名单,操作成功)", MessageBoxIcon.Success);
}
#endregion
/// <summary>
/// 查询按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnQuery_Click(object sender, EventArgs e)
{
BindGrid();
}
/// <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,d.Remark BackRemark "
+ @" FROM SubPack_LaborTeam a(NOLOCK) "
+ @" left join SubPack_Blacklist d(NOLOCK) on a.LaborTeamId=d.BlackForeignKey AND d.BlackType=@BlackType"
+ @" 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));
listStr.Add(new SqlParameter("@BlackType", Const.SubPackBlackLaborTeam));
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()));
}
if (rblState.SelectedValue == "0")
{
strSql += " AND isnull(a.State,'0')='0' ";
}
else if (rblState.SelectedValue == "1")
{
strSql += " AND isnull(a.State,'0')='1' ";
}
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 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 "";
}
protected void rblState_SelectedIndexChanged(object sender, EventArgs e)
{
BindGrid();
}
}
}