203 lines
6.8 KiB
C#
203 lines
6.8 KiB
C#
using BLL;
|
|
using Model;
|
|
using NPOI.SS.Formula.Functions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.TestRun.BeforeTestRun
|
|
{
|
|
public partial class SelectIDPPiping : PageBase
|
|
{
|
|
/// <summary>
|
|
/// ProjectId
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get { return (string)ViewState["ProjectId"]; }
|
|
set { ViewState["ProjectId"] = value; }
|
|
}
|
|
///// <summary>
|
|
///// 子系统id
|
|
///// </summary>
|
|
//public string SubSystemId
|
|
//{
|
|
// get { return (string)ViewState["SubSystemId"]; }
|
|
// set { ViewState["SubSystemId"] = value; }
|
|
//}
|
|
|
|
/// <summary>
|
|
/// 系统id
|
|
/// </summary>
|
|
public string SystemId
|
|
{
|
|
get { return (string)ViewState["SystemId"]; }
|
|
set { ViewState["SystemId"] = value; }
|
|
}
|
|
|
|
///// <summary>
|
|
///// 选中的id
|
|
///// </summary>
|
|
//public string SelectPropertyIds
|
|
//{
|
|
// get { return (string)ViewState["SelectPropertyIds"]; }
|
|
// set { ViewState["SelectPropertyIds"] = value; }
|
|
//}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
//this.SubSystemId = Request["SubSystemId"];
|
|
this.SystemId = Request["SystemId"];
|
|
//this.SelectPropertyIds = Request["SelectPropertyIds"];
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"select * from IDP_PreRunData_Piping where ProjectId=@ProjectId and ItemId not in (select PropertyId from PreRun_PropertySysPiping) ";
|
|
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();
|
|
}
|
|
|
|
#region 确认
|
|
|
|
/// <summary>
|
|
/// 确认
|
|
/// </summary>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
var lastSysPiping = Funs.DB.PreRun_PropertySysPiping.Where(x => x.ProjectId == this.ProjectId && x.SystemId == this.SystemId).OrderByDescending(x => x.Sort).FirstOrDefault();
|
|
int sortIndex = lastSysPiping != null ? (int)lastSysPiping.Sort + 1 : 1;
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
this.SaveData(Grid1.DataKeys[rowIndex][0].ToString(), sortIndex);
|
|
sortIndex++;
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="ItemId">被选中的管道Id</param>
|
|
/// <param name="weekItem">周信息</param>
|
|
/// <param name="sortIndex">计划排序</param>
|
|
private void SaveData(string ItemId, int sortIndex)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var item = db.IDP_PreRunData_Piping.FirstOrDefault(x => x.ItemId == ItemId);
|
|
if (item != null)
|
|
{
|
|
Model.PreRun_PropertySysPiping model = new Model.PreRun_PropertySysPiping();
|
|
model.ProjectId = this.ProjectId;
|
|
model.SystemId = this.SystemId;
|
|
model.PropertyId = item.ItemId;
|
|
model.PipingCode = item.PipingCode;
|
|
model.Diameter = item.Diameter;
|
|
model.MaterialLevel = item.MaterialLevel;
|
|
model.AdiabatType = item.AdiabatType;
|
|
model.AdiabatThickness = item.AdiabatThickness;
|
|
model.MediumState = item.MediumState;
|
|
model.DrawingNo = item.DrawingStartNo;
|
|
model.DrawingEndNo = item.DrawingEndNo;
|
|
model.PipingStart = item.PipingStart;
|
|
model.PipingEnd = item.PipingEnd;
|
|
model.PipingLevel = item.PipingLevel;
|
|
model.NormalTemperature = item.NormalTemperature;
|
|
model.NormalPressure = item.NormalPressure;
|
|
model.DesignTemperature = item.DesignTemperature;
|
|
model.DesignPressure = item.DesignPressure;
|
|
model.PaintLevel = item.PaintLevel;
|
|
model.Remark = item.Remark;
|
|
model.AddUser = this.CurrUser.UserId;
|
|
model.AddTime = DateTime.Now;
|
|
model.Sort = sortIndex;
|
|
db.PreRun_PropertySysPiping.InsertOnSubmit(model);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 表排序、分页、关闭窗口
|
|
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页显示条数下拉框
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉框
|
|
/// </summary>
|
|
protected void ddlPageSize_SelectedIndexChanged1(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |