470 lines
18 KiB
C#
470 lines
18 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using NPOI.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.SYBData
|
|
{
|
|
public partial class PressureTestPackageList : PageBase
|
|
{
|
|
#region 定义项
|
|
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string PressureTestPackageListId
|
|
{
|
|
get { return (string)ViewState["PressureTestPackageListId"]; }
|
|
set { ViewState["PressureTestPackageListId"] = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 项目Id
|
|
/// </summary>
|
|
private string ProjectId
|
|
{
|
|
get { return (string)ViewState["ProjectId"]; }
|
|
set { ViewState["ProjectId"] = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义集合
|
|
/// </summary>
|
|
private static List<Model.SYBData_PressureTestPackageList> items = new List<Model.SYBData_PressureTestPackageList>();
|
|
#endregion
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
|
|
this.drpProjectId.DataTextField = "ProjectCode";
|
|
this.drpProjectId.DataValueField = "ProjectId";
|
|
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
this.drpProjectId.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpProjectId);
|
|
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
|
|
this.InitTreeMenu();//加载树
|
|
this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
|
|
this.ProjectId = this.tvControlItem.SelectedNodeID;
|
|
|
|
//管线
|
|
this.drpIsoId.DataTextField = "ISO_IsoNo";
|
|
this.drpIsoId.DataValueField = "ISO_IsoNo";
|
|
this.drpIsoId.DataSource = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByProjectId(this.ProjectId);
|
|
this.drpIsoId.DataBind();
|
|
|
|
PageInfo();
|
|
}
|
|
}
|
|
|
|
private void PageInfo()
|
|
{
|
|
items.Clear();
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
var reportLists = BLL.PressureTestPackageListService.GetListsByProjectId(this.ProjectId);
|
|
if (reportLists.Count > 0)
|
|
{
|
|
var isoLists = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByProjectId(this.ProjectId);
|
|
foreach (var item in isoLists)
|
|
{
|
|
var iso = (from x in Funs.DB.SYBData_PressureTestPackageList where x.ProjectId == this.ProjectId && x.PipelineCode == item.ISO_IsoNo select x).FirstOrDefault();
|
|
if (iso == null)
|
|
{
|
|
Model.SYBData_PressureTestPackageList newReport = new Model.SYBData_PressureTestPackageList();
|
|
newReport.PressureTestPackageListId = SQLHelper.GetNewID();
|
|
newReport.ProjectId = this.ProjectId;
|
|
newReport.PipelineCode = item.ISO_IsoNo;
|
|
newReport.PressureTestPackageCode = "";
|
|
reportLists.Add(newReport);
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(this.drpIsoId.SelectedValue) && this.drpIsoId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
reportLists = reportLists.Where(x => x.PipelineCode.Contains(this.drpIsoId.SelectedValue)).ToList();
|
|
}
|
|
this.Grid1.DataSource = reportLists;
|
|
this.Grid1.DataBind();
|
|
}
|
|
else
|
|
{
|
|
var isoLists = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByProjectId(this.ProjectId);
|
|
foreach (var iso in isoLists)
|
|
{
|
|
Model.SYBData_PressureTestPackageList newReport = new Model.SYBData_PressureTestPackageList();
|
|
newReport.PressureTestPackageListId = SQLHelper.GetNewID();
|
|
newReport.ProjectId = this.ProjectId;
|
|
newReport.PipelineCode = iso.ISO_IsoNo;
|
|
newReport.PressureTestPackageCode = "";
|
|
items.Add(newReport);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.drpIsoId.SelectedValue) && this.drpIsoId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
items = items.Where(x => x.PipelineCode.Contains(this.drpIsoId.SelectedValue)).ToList();
|
|
}
|
|
this.Grid1.DataSource = items;
|
|
this.Grid1.DataBind();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载树项目
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "项目";
|
|
rootNode.ToolTip = "项目";
|
|
rootNode.NodeID = "0";
|
|
rootNode.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
|
|
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
|
|
// 默认显示选中的项目
|
|
string selectedProjectId = this.drpProjectId.SelectedValue;
|
|
if (!string.IsNullOrEmpty(selectedProjectId) && selectedProjectId != BLL.Const._Null)
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == selectedProjectId).ToList();
|
|
|
|
// 如果项目存在,则选中该节点
|
|
if (projects.Any())
|
|
{
|
|
this.tvControlItem.SelectedNodeID = selectedProjectId;
|
|
}
|
|
}
|
|
|
|
if (this.drpProjectId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == this.drpProjectId.SelectedValue).ToList();
|
|
}
|
|
foreach (var item in projects)
|
|
{
|
|
TreeNode rootProjectNode = new TreeNode();//定义根节点
|
|
rootProjectNode.Text = item.ProjectCode;
|
|
rootProjectNode.NodeID = item.ProjectId;
|
|
rootProjectNode.EnableClickEvent = true;
|
|
rootProjectNode.Expanded = true;
|
|
rootProjectNode.ToolTip = item.ProjectName;
|
|
rootProjectNode.CommandName = "项目名称";
|
|
rootNode.Nodes.Add(rootProjectNode);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
if (this.tvControlItem.SelectedNodeID != "0")
|
|
{
|
|
this.ProjectId = this.tvControlItem.SelectedNodeID;
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT * FROM SYBData_PressureTestPackageList where ProjectId=@projectId";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@projectId", this.ProjectId));
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页排序
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页选择下拉改变事件
|
|
/// <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
|
|
#endregion
|
|
|
|
#region 查询
|
|
///<summary>
|
|
///查询
|
|
///</summary>
|
|
///<param name="sender"></param>
|
|
///<param name="e"></param>
|
|
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.ProjectId = this.drpProjectId.SelectedValue;
|
|
this.InitTreeMenu();
|
|
this.tvControlItem.SelectedNodeID = this.ProjectId;
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 打印
|
|
/// <summary>
|
|
/// 打印
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
string initTemplatePath = "";
|
|
string rootPath = Server.MapPath("~/");
|
|
BLL.Common.FastReportService.ResetData();
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
listStr.Add(new SqlParameter("@projectId", this.tvControlItem.SelectedNodeID));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.drpIsoId.SelectedValue) && this.drpIsoId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
listStr.Add(new SqlParameter("@iso_no", "%" + this.drpIsoId.SelectedValue + "%"));
|
|
}
|
|
else
|
|
{
|
|
listStr.Add(new SqlParameter("@iso_no", null));
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunProc("SYB_TestPackagePipeList", parameter);
|
|
if (tb.Rows.Count > 0)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt.TableName = "Data";
|
|
dt.Columns.Add("Number1");
|
|
dt.Columns.Add("PipelineCode1");
|
|
dt.Columns.Add("TestPackageNo1");
|
|
dt.Columns.Add("Number2");
|
|
dt.Columns.Add("PipelineCode2");
|
|
dt.Columns.Add("TestPackageNo2");
|
|
|
|
DataRow[] rows = tb.DefaultView.ToTable().Select();
|
|
foreach (var row in rows)
|
|
{
|
|
var newRow = dt.NewRow();
|
|
newRow["Number1"] = row["Number1"].ToString();
|
|
newRow["PipelineCode1"] = row["PipelineCode1"].ToString();
|
|
newRow["TestPackageNo1"] = row["TestPackageNo1"].ToString();
|
|
newRow["Number2"] = row["Number2"].ToString();
|
|
newRow["PipelineCode2"] = row["PipelineCode2"].ToString();
|
|
newRow["TestPackageNo2"] = row["TestPackageNo2"].ToString();
|
|
dt.Rows.Add(newRow);
|
|
}
|
|
BLL.Common.FastReportService.AddFastreportTable(dt);
|
|
|
|
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(this.ProjectId).ProjectName);
|
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
|
|
|
initTemplatePath = "File\\Fastreport\\SYBData\\管道试压包一览表.frx";
|
|
if (File.Exists(rootPath + initTemplatePath))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowPrint.GetShowReference(String.Format("../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请先保存数据!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 维护
|
|
/// <summary>
|
|
/// 增加
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
|
|
{
|
|
JArray teamGroupData = Grid1.GetMergedData();
|
|
List<JObject> list = new List<JObject>();
|
|
foreach (JObject teamGroupRow in teamGroupData)
|
|
{
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
list.Add(values);
|
|
}
|
|
|
|
JObject defaultObj = new JObject
|
|
{
|
|
{ "PressureTestPackageListId", Guid.NewGuid() },
|
|
{ "PipelineCode", "" },
|
|
{ "PressureTestPackageCode", "" },
|
|
{
|
|
"Delete3",
|
|
String.Format("<a href=\"javascript:;\" onclick=\"{0}\"><img src=\"{1}\"/></a>",
|
|
GetDeleteScriptGrid1(), IconHelper.GetResolvedIconUrl(Icon.Delete))
|
|
}
|
|
};
|
|
list.Add(defaultObj);
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
protected void Grid1_PreDataBound(object sender, EventArgs e)
|
|
{
|
|
// 设置LinkButtonField的点击客户端事件
|
|
LinkButtonField deleteField = Grid1.FindColumn("Delete3") as LinkButtonField;
|
|
deleteField.OnClientClick = GetDeleteScriptGrid1();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除提示
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetDeleteScriptGrid1()
|
|
{
|
|
return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question,
|
|
Grid1.GetDeleteSelectedRowsReference(), String.Empty);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 提交按钮
|
|
/// <summary>
|
|
/// 提交按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.SYBData_PressureTestPackageListMenuId, Const.BtnSave))
|
|
{
|
|
items.Clear();
|
|
BLL.PressureTestPackageListService.DeleteListsByProjectId(this.ProjectId);
|
|
JArray teamGroupData = Grid1.GetMergedData();
|
|
int i = 0;
|
|
foreach (JObject teamGroupRow in teamGroupData)
|
|
{
|
|
JObject values = teamGroupRow.Value<JObject>("values");
|
|
int rowIndex = teamGroupRow.Value<int>("index");
|
|
Model.SYBData_PressureTestPackageList newDetail = new Model.SYBData_PressureTestPackageList
|
|
{
|
|
PressureTestPackageListId = values.Value<string>("PressureTestPackageListId"),
|
|
ProjectId = this.ProjectId,
|
|
SerialNumber = (i + 1).ToString(),
|
|
PipelineCode = values.Value<string>("PipelineCode"),
|
|
PressureTestPackageCode = values.Value<string>("PressureTestPackageCode"),
|
|
CompileMan = this.CurrUser.UserId,
|
|
CompileDate = DateTime.Now
|
|
};
|
|
items.Add(newDetail);
|
|
i++;
|
|
}
|
|
try
|
|
{
|
|
if (items.Count > 0)
|
|
{
|
|
Funs.DB.SYBData_PressureTestPackageList.InsertAllOnSubmit(items);
|
|
}
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return;
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
//PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void drpIsoId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
PageInfo();
|
|
}
|
|
}
|
|
} |