提交代码
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
using BLL;
|
||||
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 SelectInstrument : PageBase
|
||||
{
|
||||
/// <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 SelectInstrumentIds
|
||||
{
|
||||
get { return (string)ViewState["SelectInstrumentIds"]; }
|
||||
set { ViewState["SelectInstrumentIds"] = value; }
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.SubSystemId = Request["SubSystemId"];
|
||||
this.SystemId = Request["SystemId"];
|
||||
this.SelectInstrumentIds = Request["SelectInstrumentIds"];
|
||||
// 绑定表格
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string strSql = @"select * from PreRun_InstrumentSysPiping where ProjectId=@ProjectId and SystemId=@SystemId ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
listStr.Add(new SqlParameter("@SystemId", this.SystemId));
|
||||
if (!string.IsNullOrWhiteSpace(SelectInstrumentIds))
|
||||
{
|
||||
var ids = SelectInstrumentIds.Split(',').ToList();
|
||||
strSql += $" and InstrumentId not in ('{string.Join("','", ids)}')";
|
||||
}
|
||||
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)
|
||||
{
|
||||
var requestIds = SelectInstrumentIds.Split(',').ToList();
|
||||
string ids = SelectInstrumentIds;
|
||||
foreach (var item in this.Grid1.SelectedRowIDArray)
|
||||
{
|
||||
if (requestIds.Contains(item)) continue;
|
||||
if (string.IsNullOrWhiteSpace(ids))
|
||||
{
|
||||
ids = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
ids += "," + item;
|
||||
}
|
||||
}
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(ids) + ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
|
||||
#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