159 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			159 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			C#
		
	
	
	
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 SelectProperty : 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 SelectPropertyIds
 | 
						|
        {
 | 
						|
            get { return (string)ViewState["SelectPropertyIds"]; }
 | 
						|
            set { ViewState["SelectPropertyIds"] = value; }
 | 
						|
        }
 | 
						|
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                this.SubSystemId = Request["SubSystemId"];
 | 
						|
                this.SystemId = Request["SystemId"];
 | 
						|
                this.SelectPropertyIds = Request["SelectPropertyIds"];
 | 
						|
                // 绑定表格
 | 
						|
                BindGrid();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 绑定数据
 | 
						|
        /// </summary>
 | 
						|
        private void BindGrid()
 | 
						|
        {
 | 
						|
            //string strSql = @"select * from PreRun_PropertySysPiping where ProjectId=@ProjectId and SystemId=@SystemId and PropertyId not in (select PropertyId from PreRun_SubPropertySelect where SystemId=@SystemId) ";
 | 
						|
            string strSql = @"select * from PreRun_PropertySysPiping where ProjectId=@ProjectId and SystemId=@SystemId and PropertyId not in (select PropertyId from PreRun_SubPropertySelect) ";
 | 
						|
            List<SqlParameter> listStr = new List<SqlParameter>();
 | 
						|
            listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
 | 
						|
            listStr.Add(new SqlParameter("@SystemId", this.SystemId));
 | 
						|
            //if (!string.IsNullOrWhiteSpace(SelectPropertyIds))
 | 
						|
            //{
 | 
						|
            //    var ids = SelectPropertyIds.Split(',').ToList();
 | 
						|
            //    strSql += $" and PropertyId 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 = SelectPropertyIds.Split(',').ToList();
 | 
						|
            string ids = SelectPropertyIds;
 | 
						|
            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
 | 
						|
 | 
						|
    }
 | 
						|
} |