397 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			397 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using Model;
 | |
| using Newtonsoft.Json.Linq;
 | |
| 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;
 | |
| using System.Threading.Tasks;
 | |
| 
 | |
| namespace FineUIPro.Web.TestRun.BeforeTestRun
 | |
| {
 | |
|     public partial class IDPPreRunData : PageBase
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 项目id
 | |
|         /// </summary>
 | |
|         public string ProjectId
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 return (string)ViewState["ProjectId"];
 | |
|             }
 | |
|             set
 | |
|             {
 | |
|                 ViewState["ProjectId"] = value;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 this.ProjectId = this.CurrUser.LoginProjectId;
 | |
|                 Funs.DropDownPageSize(this.ddlPageSize);
 | |
|                 Funs.DropDownPageSize(this.ddlPageSize2);
 | |
|                 Funs.DropDownPageSize(this.ddlPageSize3);
 | |
|                 ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
 | |
|                 ddlPageSize2.SelectedValue = Grid2.PageSize.ToString();
 | |
|                 ddlPageSize3.SelectedValue = Grid3.PageSize.ToString();
 | |
|                 BindPipingGrid();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Tab切换
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void TabStrip1_TabIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (TabStrip1.ActiveTabIndex == 1)
 | |
|             {
 | |
|                 if (this.Grid2.Rows.Count == 0)
 | |
|                 {
 | |
|                     BindEquipmentGrid();
 | |
|                 }
 | |
|             }
 | |
|             else if (TabStrip1.ActiveTabIndex == 2)
 | |
|             {
 | |
|                 if (this.Grid3.Rows.Count == 0)
 | |
|                 {
 | |
|                     BindInstrumentationGrid();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 从IDP获取数据
 | |
|         /// </summary>
 | |
|         protected void btnGetIDPData_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                 string msg = GetIDPPreRunData(1);
 | |
|                 if (!string.IsNullOrWhiteSpace(msg))
 | |
|                 {
 | |
|                     if (msg.Contains("成功"))
 | |
|                     {
 | |
|                         ShowNotify(msg);
 | |
|                         BindPipingGrid();
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         ShowNotify(msg, MessageBoxIcon.Error);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception ex)
 | |
|             {
 | |
|                 ShowNotify(ex.Message, MessageBoxIcon.Error);
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 从IDP获取数据
 | |
|         /// </summary>
 | |
|         protected void btnGetIDPData2_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                 string msg = GetIDPPreRunData(2);
 | |
|                 if (!string.IsNullOrWhiteSpace(msg))
 | |
|                 {
 | |
|                     if (msg.Contains("成功"))
 | |
|                     {
 | |
|                         ShowNotify(msg);
 | |
|                         BindEquipmentGrid();
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         ShowNotify(msg, MessageBoxIcon.Error);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception ex)
 | |
|             {
 | |
|                 ShowNotify(ex.Message, MessageBoxIcon.Error);
 | |
|             }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         #region 管道一览表
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 行点击事件
 | |
|         /// </summary>
 | |
|         protected void PipingGrid_RowCommand(object sender, GridCommandEventArgs e)
 | |
|         {
 | |
|             if (e.CommandName == "Detail")
 | |
|             {
 | |
|                 string itemId = e.RowID;
 | |
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("IDPPreRunDataDetail.aspx?Type=1&ItemId={0}", itemId)));
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取IDP试车数据
 | |
|         /// </summary>
 | |
|         /// <param name="type"></param>
 | |
|         /// <returns></returns>
 | |
|         private string GetIDPPreRunData(int type)
 | |
|         {
 | |
|             string result = string.Empty;
 | |
|             var session = IDPDataService.GetAuthenticationSession();
 | |
| 
 | |
|             if (type == 1)
 | |
|             {
 | |
|                 string pipingMsg = IDPDataService.GetIDPProjectPreRunDataPiping(session, this.ProjectId);
 | |
|                 result = pipingMsg;
 | |
|             }
 | |
|             else if (type == 2)
 | |
|             {
 | |
|                 string equipmentMsg = IDPDataService.GetIDPProjectPreRunDataEquipment(session, this.ProjectId);
 | |
|                 result = equipmentMsg;
 | |
|             }
 | |
|             else if (type == 3)
 | |
|             {
 | |
|                 string instrumentationMsg = IDPDataService.GetIDPProjectPreRunDataInstrumentation(session, this.ProjectId);
 | |
|                 result = instrumentationMsg;
 | |
|             }
 | |
|             return result;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// IDP项目管道数据
 | |
|         /// </summary>
 | |
|         private void BindPipingGrid()
 | |
|         {
 | |
|             string strSql = @"select * from IDP_PreRunData_Piping p where 1=1 ";
 | |
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | |
|             string cpara = string.Empty;
 | |
|             if (!string.IsNullOrWhiteSpace(this.ProjectId))
 | |
|             {
 | |
|                 strSql += " AND p.ProjectId = @projectId";
 | |
|                 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();
 | |
|         }
 | |
| 
 | |
|         #region 表排序、分页、关闭窗口
 | |
|         /// <summary>
 | |
|         /// 分页
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | |
|         {
 | |
|             BindPipingGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 排序
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_Sort(object sender, GridSortEventArgs e)
 | |
|         {
 | |
|             BindPipingGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 分页显示条数下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
 | |
|             BindPipingGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
| 
 | |
|         #region 设备一览表
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 行点击事件
 | |
|         /// </summary>
 | |
|         protected void EquipmentGrid_RowCommand(object sender, GridCommandEventArgs e)
 | |
|         {
 | |
|             if (e.CommandName == "Detail")
 | |
|             {
 | |
|                 string itemId = e.RowID;
 | |
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("IDPPreRunDataDetail.aspx?Type=2&ItemId={0}", itemId)));
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// IDP项目管道数据
 | |
|         /// </summary>
 | |
|         private void BindEquipmentGrid()
 | |
|         {
 | |
|             string strSql = @"select * from IDP_PreRunData_Equipment p where 1=1 ";
 | |
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | |
|             string cpara = string.Empty;
 | |
|             if (!string.IsNullOrWhiteSpace(this.ProjectId))
 | |
|             {
 | |
|                 strSql += " AND p.ProjectId = @projectId";
 | |
|                 listStr.Add(new SqlParameter("@projectId", this.ProjectId));
 | |
|             }
 | |
|             SqlParameter[] parameter = listStr.ToArray();
 | |
|             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | |
|             Grid2.RecordCount = tb.Rows.Count;
 | |
|             var table = this.GetPagedDataTable(Grid2, tb);
 | |
|             Grid2.DataSource = table;
 | |
|             Grid2.DataBind();
 | |
|         }
 | |
| 
 | |
|         #region 表排序、分页、关闭窗口
 | |
|         /// <summary>
 | |
|         /// 分页
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e)
 | |
|         {
 | |
|             BindEquipmentGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 排序
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid2_Sort(object sender, GridSortEventArgs e)
 | |
|         {
 | |
|             BindEquipmentGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 分页显示条数下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void ddlPageSize2_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             Grid2.PageSize = Convert.ToInt32(ddlPageSize2.SelectedValue);
 | |
|             BindEquipmentGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|      
 | |
|         #region 仪表索引
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 行点击事件
 | |
|         /// </summary>
 | |
|         protected void InstrumentationGrid_RowCommand(object sender, GridCommandEventArgs e)
 | |
|         {
 | |
|             if (e.CommandName == "Detail")
 | |
|             {
 | |
|                 string itemId = e.RowID;
 | |
|                 PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("IDPPreRunDataDetail.aspx?Type=3&ItemId={0}", itemId)));
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 从IDP获取数据
 | |
|         /// </summary>
 | |
|         protected void btnGetIDPData3_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                 string msg = GetIDPPreRunData(3);
 | |
|                 if (!string.IsNullOrWhiteSpace(msg))
 | |
|                 {
 | |
|                     if (msg.Contains("成功"))
 | |
|                     {
 | |
|                         ShowNotify(msg);
 | |
|                         BindInstrumentationGrid();
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         ShowNotify(msg, MessageBoxIcon.Error);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception ex)
 | |
|             {
 | |
|                 ShowNotify(ex.Message, MessageBoxIcon.Error);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// IDP项目仪表索引数据
 | |
|         /// </summary>
 | |
|         private void BindInstrumentationGrid()
 | |
|         {
 | |
|             string strSql = @"select * from IDP_PreRunData_Instrumentation p where 1=1 ";
 | |
|             List<SqlParameter> listStr = new List<SqlParameter>();
 | |
|             string cpara = string.Empty;
 | |
|             if (!string.IsNullOrWhiteSpace(this.ProjectId))
 | |
|             {
 | |
|                 strSql += " AND p.ProjectId = @projectId";
 | |
|                 listStr.Add(new SqlParameter("@projectId", this.ProjectId));
 | |
|             }
 | |
|             SqlParameter[] parameter = listStr.ToArray();
 | |
|             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | |
|             Grid3.RecordCount = tb.Rows.Count;
 | |
|             var table = this.GetPagedDataTable(Grid3, tb);
 | |
|             Grid3.DataSource = table;
 | |
|             Grid3.DataBind();
 | |
|         }
 | |
| 
 | |
|         #region 表排序、分页、关闭窗口
 | |
|         /// <summary>
 | |
|         /// 分页
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid3_PageIndexChange(object sender, GridPageEventArgs e)
 | |
|         {
 | |
|             BindInstrumentationGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 排序
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid3_Sort(object sender, GridSortEventArgs e)
 | |
|         {
 | |
|             BindInstrumentationGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 分页显示条数下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void ddlPageSize3_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             Grid3.PageSize = Convert.ToInt32(ddlPageSize3.SelectedValue);
 | |
|             BindInstrumentationGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|     }
 | |
| } |