对接IDP系统项目开车数据
This commit is contained in:
@@ -0,0 +1,197 @@
|
||||
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 SelectIDPInstrumentation : 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_Instrumentation where ProjectId=@ProjectId and ItemId not in (select InstrumentId from PreRun_InstrumentSysPiping) ";
|
||||
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_InstrumentSysPiping.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_Instrumentation.FirstOrDefault(x => x.ItemId == ItemId);
|
||||
if (item != null)
|
||||
{
|
||||
Model.PreRun_InstrumentSysPiping model = new Model.PreRun_InstrumentSysPiping();
|
||||
model.ProjectId = this.ProjectId;
|
||||
model.SystemId = this.SystemId;
|
||||
model.InstrumentId = item.ItemId;
|
||||
model.InstrumentTag = item.InstrumentTag;
|
||||
model.UseTo = item.UseTo;
|
||||
model.InstrumentName = item.InstrumentName;
|
||||
model.Supplier = item.Supplier;
|
||||
model.InstallationPosition = item.InstallationPosition;
|
||||
model.SignalType = item.SignalType;
|
||||
model.AssociatedSystem = item.AssociatedSystem;
|
||||
model.Cp25 = item.Cp25;
|
||||
model.In11 = item.In11;
|
||||
model.In40 = item.In40;
|
||||
model.Remark = item.Remark;
|
||||
model.AddUser = this.CurrUser.UserId;
|
||||
model.AddTime = DateTime.Now;
|
||||
model.Sort = sortIndex;
|
||||
db.PreRun_InstrumentSysPiping.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
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user