xinjiang/SGGL/FineUIPro.Web/HJGL/TrustManage/ShowTrustSearch.aspx.cs

353 lines
11 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using BLL;
namespace FineUIPro.Web.HJGL.TrustManage
{
public partial class ShowTrustSearch : PageBase
{
#region
/// <summary>
/// 单位主键
/// </summary>
public string UnitId
{
get
{
return (string)ViewState["UnitId"];
}
set
{
ViewState["UnitId"] = value;
}
}
/// <summary>
/// 装置主键
/// </summary>
public string InstallationId
{
get
{
return (string)ViewState["InstallationId"];
}
set
{
ViewState["InstallationId"] = value;
}
}
/// <summary>
/// 焊口主键
/// </summary>
public string Jot_ID
{
get
{
return (string)ViewState["Jot_ID"];
}
set
{
ViewState["Jot_ID"] = value;
}
}
/// <summary>
/// 日报主键
/// </summary>
public string DReportID
{
get
{
return (string)ViewState["DReportID"];
}
set
{
ViewState["DReportID"] = value;
}
}
/// <summary>
/// 项目
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
/// <summary>
/// 被选择项列表
/// </summary>
public List<string> SelectedList
{
get
{
return (List<string>)ViewState["SelectedList"];
}
set
{
ViewState["SelectedList"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.SelectedList = new List<string>();
//this.NoSelectedList = new List<string>();
string strList = Request.Params["strList"];
List<string> list = Funs.GetStrListByStr(strList, '|');
if (list.Count() == 4)
{
this.ProjectId = list[0];
this.UnitId = list[1];
this.DReportID = list[2];
this.InstallationId = list[3];
BLL.WorkAreaService.InitWorkAreaProjectInstallUnitDropDownList(this.drpWorkArea, this.CurrUser.LoginProjectId, this.InstallationId, this.UnitId, true);
}
//this.InitTreeMenu();//加载树
}
}
#endregion
#region
/// <summary>
/// 加载树
/// </summary>
private void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
TreeNode rootNode = new TreeNode();
rootNode.Text = "点口单号";
rootNode.NodeID = "0";
rootNode.Expanded = true;
this.tvControlItem.Nodes.Add(rootNode);
var viewTrustSearchLists = (from x in Funs.DB.View_CH_TrustSearch
where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == UnitId
orderby x.PW_PointNo
select x).ToList();
if (this.drpWorkArea.SelectedValue != BLL.Const._Null)
{
viewTrustSearchLists = (from x in viewTrustSearchLists where x.WorkAreaId == this.drpWorkArea.SelectedValue orderby x.ISO_IsoNo select x).ToList();
}
if (!string.IsNullOrEmpty(this.txtIsono.Text))
{
viewTrustSearchLists = (from x in viewTrustSearchLists where x.ISO_IsoNo.Contains(this.txtIsono.Text.Trim()) orderby x.ISO_IsoNo select x).ToList();
}
var list = (from x in viewTrustSearchLists select new { x.PW_PointID, x.PW_PointNo }).Distinct().ToList();
foreach (var item in list)
{
TreeNode newNode = new TreeNode();
newNode.Text = item.PW_PointNo;
newNode.NodeID = item.PW_PointID;
newNode.ToolTip = item.PW_PointNo;
newNode.EnableClickEvent = true;
rootNode.Nodes.Add(newNode);
}
}
#endregion
protected void txtJOT_JointNo_TextChanged(object sender, EventArgs e)
{
BindGrid();
}
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindGrid()
{
string pW_PointID = this.tvControlItem.SelectedNodeID;
string strSql = @"SELECT 0 [index], jot.JOT_ID,jot.JOT_JointNo,jot.ISO_IsoNo,jot.JOT_JointDesc,
jot.ISO_ID,case jot.JOT_JointStatus when '101' then '点口' when '102' then '扩透' else '' end as JOT_JointStatus
FROM dbo.View_CH_TrustSearch jot
WHERE jot.ProjectId=@ProjectId AND jot.PW_PointID=@PW_PointID";
if (!string.IsNullOrEmpty(txtJOT_JointNo.Text))
{
strSql += " and jot.JOT_JointNo like '%"+ txtJOT_JointNo .Text+ "%'";
}
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
listStr.Add(new SqlParameter("@PW_PointID", pW_PointID));
strSql += " ORDER BY CONVERT(INT,dbo.Fun_GetParseInt(jot.JOT_JointNo))";
SqlParameter[] parameter = listStr.ToArray();
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
string jotIds = Request.Params["jotIds"];
if (!string.IsNullOrEmpty(jotIds))
{
string[] jots = jotIds.Split('|');
foreach (string jotId in jots)
{
DataRow r = dt.Select("JOT_ID='" + jotId + "'").FirstOrDefault();
if (r != null)
{
dt.Rows.Remove(r);
}
//Model.HJGL_SpRpWeldReportItem item = toDoMatterList.FirstOrDefault(e => e.JOT_ID == jotId);
//if (item != null)
//{
// toDoMatterList.Remove(item);
//}
}
}
if (dt != null)
{
foreach (DataRow row in dt.Rows)
{
try
{
row["index"] = int.Parse(System.Text.RegularExpressions.Regex.Replace(row["JOT_JointNo"].ToString(), @"[^0-9]+", ""));
}
catch (Exception e)
{
}
}
}
//DataTable tb = this.LINQToDataTable(toDoMatterList);
// 2.获取当前分页数据
Grid1.RecordCount = dt.Rows.Count;
//var table = this.GetPagedDataTable(Grid1, dt);
//tb = GetFilteredTable(Grid1.FilteredData, tb);
Grid1.DataSource = dt;
Grid1.DataBind();
//string[] arr = new string[this.Grid1.Rows.Count];
//int a = 0;
//for (int i = 0; i < this.Grid1.Rows.Count; i++)
//{
// string rowId = this.Grid1.Rows[i].DataKeys[0].ToString();
// if (jotIds.Contains(rowId))
// {
// arr[a] = rowId;
// }
// a++;
//}
//Grid1.SelectedRowIDArray = arr;
}
#endregion
#region 线
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Tree_TextChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
this.BindGrid();
}
#endregion
#region TreeView
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
string[] selectRowId = Grid1.SelectedRowIDArray;
for (int i = 0; i < this.Grid1.Rows.Count; i++)
{
string rowId = this.Grid1.Rows[i].DataKeys[0].ToString();
if (selectRowId.Contains(rowId))
{
SelectedList.Add(rowId);
}
//else
//{
// NoSelectedList.Add(rowId);
//}
}
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
this.BindGrid();
}
#endregion
//protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
//{
// BindGrid();
//}
#region
/// <summary>
/// 提交按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAccept_Click(object sender, EventArgs e)
{
string itemsString = string.Empty;
string[] selectRowId = Grid1.SelectedRowIDArray;
for (int i = 0; i < this.Grid1.Rows.Count; i++)
{
string rowId = this.Grid1.Rows[i].DataKeys[0].ToString();
if (selectRowId.Contains(rowId))
{
SelectedList.Add(rowId);
}
}
string jotIds = Request.Params["jotIds"];
if (!string.IsNullOrEmpty(jotIds))
{
string[] jots = jotIds.Split('|');
foreach (string jotId in jots)
{
SelectedList.Add(jotId);
}
}
var welders = from x in Funs.DB.BS_Welder where x.ProjectId == this.CurrUser.LoginProjectId && x.WED_Unit == this.UnitId select x;
foreach (var item in SelectedList)
{
if (!itemsString.Contains(item))
{
itemsString += item + "|";
}
}
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(itemsString)
+ ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}