311 lines
9.8 KiB
C#
311 lines
9.8 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HJGL.TestPackageManage
|
|
{
|
|
public partial class ShowTestPackageSearch : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 单位ID
|
|
/// </summary>
|
|
public string UnitId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["UnitId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["UnitId"] = value;
|
|
}
|
|
}
|
|
public string selectedList
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["selectedList"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["selectedList"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 装置
|
|
/// </summary>
|
|
public string InstallationId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["InstallationId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["InstallationId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择列表
|
|
/// </summary>
|
|
public List<string> CheckList
|
|
{
|
|
get
|
|
{
|
|
return (List<string>)ViewState["CheckList"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["CheckList"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择列表
|
|
/// </summary>
|
|
public List<string> isoList
|
|
{
|
|
get
|
|
{
|
|
return (List<string>)ViewState["isoList"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["isoList"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义集合
|
|
/// </summary>
|
|
private static List<Model.View_TestPackageSearch> viewTestPackageSearchList = new List<Model.View_TestPackageSearch>();
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.UnitId = Request.Params["unitId"];
|
|
this.InstallationId = Request.Params["installationId"];
|
|
selectedList = "";
|
|
var unit = BLL.UnitService.GetUnitByUnitId(this.CurrUser.UnitId);
|
|
if (BLL.WorkAreaService.IsSupervisor(this.CurrUser.UnitId, this.CurrUser.LoginProjectId))
|
|
{
|
|
BLL.WorkAreaService.GetWorkAreaListByInstallSupervisorUnit(this.drpWorkArea, this.CurrUser.LoginProjectId, this.InstallationId, this.UnitId, this.CurrUser.UnitId, true);
|
|
}
|
|
else
|
|
{
|
|
BLL.WorkAreaService.GetWorkAreaListByInstallUnit(this.drpWorkArea, this.CurrUser.LoginProjectId, this.InstallationId, this.UnitId, true);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
///查询按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
viewTestPackageSearchList.Clear();
|
|
this.Grid1.DataSource = viewTestPackageSearchList;
|
|
this.Grid1.DataBind();
|
|
List<string> workAreaIds = new List<string>();
|
|
if (this.drpWorkArea.SelectedValue != BLL.Const._Null)
|
|
{
|
|
workAreaIds.Add(this.drpWorkArea.SelectedValue);
|
|
}
|
|
BindGrid(workAreaIds);
|
|
//this.InitTreeMenu(workAreaId);//加载树
|
|
//if (tvControlItem.GetCheckedNodes().Length > 0)
|
|
//{
|
|
// tvControlItem_NodeCheck(null, null);
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载树
|
|
/// <summary>
|
|
/// 加载树节点
|
|
/// </summary>
|
|
/// <param name="selectedValue"></param>
|
|
private void InitTreeMenu(string workAreaId)
|
|
{
|
|
if (!string.IsNullOrEmpty(workAreaId))
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = BLL.WorkAreaService.GetWorkAreaCodeByWorkAreaId(workAreaId);
|
|
rootNode.NodeID = workAreaId;
|
|
rootNode.Expanded = true;
|
|
rootNode.EnableCheckEvent = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
}
|
|
else
|
|
{
|
|
var workAreas = (from x in Funs.DB.ProjectData_WorkArea where x.UnitId == UnitId && x.InstallationId == InstallationId select x).ToList();
|
|
foreach (var item in workAreas)
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = item.WorkAreaCode;
|
|
rootNode.NodeID = item.WorkAreaId;
|
|
rootNode.Expanded = true;
|
|
rootNode.EnableCheckEvent = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Tree点击事件
|
|
/// <summary>
|
|
/// 点击Tree
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCheck(object sender, TreeCheckEventArgs e)
|
|
{
|
|
CheckList = new List<string>();
|
|
TreeNode[] nodes = tvControlItem.GetCheckedNodes();
|
|
if (nodes.Length > 0)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (TreeNode node in nodes)
|
|
{
|
|
CheckList.Add(node.NodeID);
|
|
}
|
|
}
|
|
|
|
BindGrid(CheckList);
|
|
}
|
|
#endregion
|
|
protected void drpWorkArea_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
List<string> workAreaIds = new List<string>();
|
|
if (this.drpWorkArea.SelectedValue != BLL.Const._Null)
|
|
{
|
|
HashSet<string> selectedSet = new HashSet<string>();
|
|
if (!string.IsNullOrEmpty(selectedList))
|
|
{
|
|
string[] ids = selectedList.Split(',');
|
|
foreach (string id in ids)
|
|
{
|
|
selectedSet.Add(id);
|
|
}
|
|
}
|
|
foreach (var item in Grid1.SelectedRowIDArray)
|
|
{
|
|
selectedSet.Add(item);
|
|
}
|
|
|
|
selectedList = string.Join(",", selectedSet.ToArray());
|
|
workAreaIds.Add(this.drpWorkArea.SelectedValue);
|
|
BindGrid(workAreaIds);
|
|
}
|
|
|
|
}
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
/// <param name="isoId"></param>
|
|
private void BindGrid(List<string> checkList)
|
|
{
|
|
viewTestPackageSearchList = (from x in Funs.DB.View_TestPackageSearch where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
|
|
if (!string.IsNullOrEmpty(this.txtISO_ID.Text.Trim()))
|
|
{
|
|
viewTestPackageSearchList = viewTestPackageSearchList.Where(e => e.ISO_IsoNo.Contains(this.txtISO_ID.Text.Trim())).ToList();
|
|
}
|
|
if (checkList != null)
|
|
{
|
|
viewTestPackageSearchList = viewTestPackageSearchList.Where(e => checkList.Contains(e.WorkAreaId)).ToList();
|
|
}
|
|
this.Grid1.DataSource = viewTestPackageSearchList;
|
|
this.Grid1.DataBind();
|
|
|
|
if (!string.IsNullOrEmpty(selectedList))
|
|
{ string[] ids = selectedList.Split(',');
|
|
List<string> needSelected = new List<string>();
|
|
foreach(var id in ids)
|
|
{
|
|
foreach(var item in viewTestPackageSearchList)
|
|
{
|
|
if (id == item.ISO_ID)
|
|
{
|
|
needSelected.Add(id);
|
|
}
|
|
}
|
|
}
|
|
this.Grid1.SelectedRowIDArray = needSelected.ToArray();
|
|
}
|
|
|
|
this.GetCheckgvList();
|
|
}
|
|
#endregion
|
|
|
|
#region 选择列表某项事件
|
|
/// <summary>
|
|
/// 选择列表某项事件
|
|
/// </summary>
|
|
private void GetCheckgvList()
|
|
{
|
|
isoList = new List<string>();
|
|
foreach (var item in viewTestPackageSearchList)
|
|
{
|
|
isoList.Add(item.ISO_ID);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 确定按钮
|
|
/// <summary>
|
|
/// 确定按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSure_Click(object sender, EventArgs e)
|
|
{
|
|
HashSet<string> selectedSet = new HashSet<string>();
|
|
if (!string.IsNullOrEmpty(selectedList))
|
|
{
|
|
string[] ids = selectedList.Split(',');
|
|
foreach (string id in ids)
|
|
{
|
|
selectedSet.Add(id);
|
|
}
|
|
}
|
|
foreach (var item in Grid1.SelectedRowIDArray)
|
|
{
|
|
selectedSet.Add(item);
|
|
}
|
|
|
|
string res = string.Join(",", selectedSet.ToArray());
|
|
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(res)
|
|
+ ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |