307 lines
11 KiB
C#
307 lines
11 KiB
C#
using BLL;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.YLRQ.HardProessManage
|
|
{
|
|
public partial class HardProessTrustItemEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } }
|
|
/// <summary>
|
|
/// 单位主键
|
|
/// </summary>
|
|
public string UnitId { get { return (string)ViewState["UnitId"]; } set { ViewState["UnitId"] = value; } }
|
|
/// <summary>
|
|
/// 硬度委托主键
|
|
/// </summary>
|
|
public string HardProessTrustId { get { return (string)ViewState["HardProessTrustId"]; } set { ViewState["HardProessTrustId"] = value; } }
|
|
/// <summary>
|
|
/// 选择内容字符串
|
|
/// </summary>
|
|
public string ItemsString { get { return (string)ViewState["ItemsString"]; } set { ViewState["ItemsString"] = value; } }
|
|
|
|
#endregion
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
ItemsString = string.Empty;
|
|
string strList = Request.Params["strList"];
|
|
List<string> list = Funs.GetStrListByStr(strList, '|');
|
|
if (list.Count() == 3)
|
|
{
|
|
this.UnitId = list[0];
|
|
this.HardProessTrustId = list[1];
|
|
this.ProjectId = list[2];
|
|
this.InitTreeMenu();//加载树
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载数
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "施工号";
|
|
rootNode.NodeID = "0";
|
|
rootNode.ToolTip = "绿色表示焊缝编号下有已焊接的焊口未委托硬度";
|
|
rootNode.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
var HardProessItems = from x in Funs.DB.PV_HardProessItem select x;
|
|
var project = Funs.DB.Base_Project.FirstOrDefault(p => p.ProjectId == this.ProjectId);
|
|
var jots = Funs.DB.PV_View_CH_HardProessTrustItem.Where(p => p.ProjectId == this.ProjectId && p.IsNeedHardTest == true);
|
|
if (jots.Count() > 0)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.NodeID = this.ProjectId;
|
|
bool isHartProess = true; //默认已完成硬度委托
|
|
foreach (var item in jots)
|
|
{
|
|
if (!string.IsNullOrEmpty(item.HardProessTrustId))
|
|
{
|
|
isHartProess = false; //未完成硬度委托
|
|
break;
|
|
}
|
|
}
|
|
if (isHartProess)
|
|
{
|
|
newNode.Text = project.ProjectCode;
|
|
}
|
|
else
|
|
{
|
|
newNode.Text = "<font color='#009966'>" + project.ProjectCode + "</font>";
|
|
}
|
|
newNode.EnableClickEvent = true;
|
|
rootNode.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
#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 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
var toDoMatterList = Funs.DB.PV_View_CH_HardProessTrustItem.Where(p => p.ProjectId == this.ProjectId && p.IsNeedHardTest == true && p.HardProessTrustId == null).ToList();
|
|
string hotProessTrustItemIds = Request.Params["hotProessTrustItemIds"];
|
|
if (!string.IsNullOrEmpty(hotProessTrustItemIds))
|
|
{
|
|
string[] jots = hotProessTrustItemIds.Split('|');
|
|
foreach (string jotId in jots)
|
|
{
|
|
PV_View_CH_HardProessTrustItem item = toDoMatterList.FirstOrDefault(e => e.HotProessTrustItemId == jotId);
|
|
if (item != null)
|
|
{
|
|
toDoMatterList.Remove(item);
|
|
}
|
|
}
|
|
}
|
|
DataTable tb = this.LINQToDataTable(toDoMatterList);
|
|
// 2.获取当前分页数据
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#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;
|
|
int n = 0;
|
|
int j = 0;
|
|
int[] selections = new int[selectRowId.Count()];
|
|
foreach (GridRow row in Grid1.Rows)
|
|
{
|
|
if (selectRowId.Contains(row.DataKeys[0]))
|
|
{
|
|
selections[n] = j;
|
|
n++;
|
|
}
|
|
j++;
|
|
}
|
|
var select = selections.Distinct();
|
|
foreach (int i in select)
|
|
{
|
|
string rowID = Grid1.DataKeys[i][0].ToString();
|
|
string hotProessTrustId = Grid1.DataKeys[i][1].ToString(); //Grid1.Rows[i].Values[4].ToString();
|
|
string hotProessTrustItemId = Grid1.DataKeys[i][2].ToString();//Grid1.Rows[i].Values[5].ToString();
|
|
string ids = rowID;
|
|
if (!string.IsNullOrEmpty(hotProessTrustId))
|
|
{
|
|
ids += "," + hotProessTrustId;
|
|
}
|
|
if (!string.IsNullOrEmpty(hotProessTrustItemId))
|
|
{
|
|
ids += "," + hotProessTrustItemId;
|
|
}
|
|
if (!ItemsString.Contains(rowID))
|
|
{
|
|
ItemsString += ids + "|";
|
|
}
|
|
}
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 提交按钮
|
|
/// <summary>
|
|
/// 提交按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAccept_Click(object sender, EventArgs e)
|
|
{
|
|
string itemsString = "";
|
|
string[] selectRowId = Grid1.SelectedRowIDArray;
|
|
int n = 0;
|
|
int j = 0;
|
|
int[] selections = new int[selectRowId.Count()];
|
|
foreach (GridRow row in Grid1.Rows)
|
|
{
|
|
if (selectRowId.Contains(row.DataKeys[2]))
|
|
{
|
|
selections[n] = j;
|
|
n++;
|
|
}
|
|
j++;
|
|
}
|
|
var select = selections.Distinct();
|
|
string hotProessTrustItemIds = Request.Params["hotProessTrustItemIds"];
|
|
if (!string.IsNullOrEmpty(hotProessTrustItemIds))
|
|
{
|
|
string[] jots = hotProessTrustItemIds.Split('|');
|
|
foreach (string jotId in jots)
|
|
{
|
|
itemsString += jotId + "|";
|
|
}
|
|
}
|
|
foreach (int i in select)
|
|
{
|
|
string rowID = Grid1.DataKeys[i][0].ToString();
|
|
string hotProessTrustId = Grid1.DataKeys[i][1].ToString(); //Grid1.Rows[i].Values[4].ToString();
|
|
string hotProessTrustItemId = Grid1.DataKeys[i][2].ToString(); //Grid1.Rows[i].Values[5].ToString();
|
|
string jointDesc = Grid1.DataKeys[i][3].ToString();//Grid1.Rows[i].Values[6].ToString();
|
|
string ids = rowID;
|
|
if (!string.IsNullOrEmpty(hotProessTrustId))
|
|
{
|
|
ids += "," + hotProessTrustId;
|
|
}
|
|
if (!string.IsNullOrEmpty(hotProessTrustItemId))
|
|
{
|
|
ids += "," + hotProessTrustItemId;
|
|
}
|
|
if (!itemsString.Contains(rowID))
|
|
{
|
|
itemsString += ids + "|";
|
|
}
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(itemsString + ItemsString)
|
|
+ ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 得到委托情况
|
|
/// </summary>
|
|
/// <param name="bigType"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertHartProessState(object hotProessTrustItemId)
|
|
{
|
|
string state = string.Empty;
|
|
if (hotProessTrustItemId != null)
|
|
{
|
|
string hotProessTrustItem_Id = hotProessTrustItemId.ToString();
|
|
var list = from x in Funs.DB.PV_View_CH_HardProessTrustItem where x.HotProessTrustItemId == hotProessTrustItem_Id select x;
|
|
foreach (var item in list)
|
|
{
|
|
if (!string.IsNullOrEmpty(item.HardProessTrustId)) //存在委托信息
|
|
{
|
|
string date = string.Empty;
|
|
if (item.TrustDate != null)
|
|
{
|
|
date = "(" + string.Format("{0:yyyy-MM-dd}", item.TrustDate) + ")";
|
|
}
|
|
state += date + ";";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(state))
|
|
{
|
|
state = state.Substring(0, state.LastIndexOf(";"));
|
|
}
|
|
}
|
|
return state;
|
|
}
|
|
|
|
#region 格式化字符串
|
|
/// <summary>
|
|
/// 得到热处理类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected string ConvertProessTypes(object proessTypes)
|
|
{
|
|
var types = proessTypes.ToString();
|
|
string result = HJGL_PW_JointInfoService.ConvertProessTypes(types);
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |