提交代码
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.TestRun.DriverPrepare
|
||||
{
|
||||
public partial class SchemePlanItemSelect : PageBase
|
||||
{
|
||||
|
||||
#region 加载页面
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.BindGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.BindGrid();
|
||||
}
|
||||
|
||||
#region 数据绑定
|
||||
/// <summary>
|
||||
/// 数据绑定
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string strSql = @"SELECT *
|
||||
FROM dbo.DriverPrepare_SchemePlanItem
|
||||
WHERE SchemePlanId=@SchemePlanId";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@SchemePlanId", this.rblType.SelectedValue));
|
||||
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();
|
||||
|
||||
Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId);
|
||||
if (plan != null)
|
||||
{
|
||||
var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId);
|
||||
List<string> nameLists = items.Select(x => x.SolutionName).ToList();
|
||||
List<string> ids = new List<string>();
|
||||
foreach (GridRow row in Grid1.Rows)
|
||||
{
|
||||
if (nameLists.Contains(row.DataKeys[1].ToString()))
|
||||
{
|
||||
ids.Add(row.RowID);
|
||||
}
|
||||
}
|
||||
this.Grid1.SelectedRowIDArray = ids.ToArray();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 排序
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
this.BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 确定按钮
|
||||
/// <summary>
|
||||
/// 确定按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnAccept_Click(object sender, EventArgs e)
|
||||
{
|
||||
string schemePlanId = Request.Params["SchemePlanId"];
|
||||
Model.DriverPrepare_SchemePlan newData = new Model.DriverPrepare_SchemePlan();
|
||||
newData.SchemePlanCode = "001";
|
||||
newData.SchemePlanName = "开车方案编制计划";
|
||||
newData.CompileMan = this.CurrUser.UserId;
|
||||
newData.CompileDate = DateTime.Now;
|
||||
newData.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (!string.IsNullOrEmpty(schemePlanId))
|
||||
{
|
||||
newData.SchemePlanId = schemePlanId;
|
||||
BLL.DriverPrepareSchemePlanService.UpdateDriverPrepareDriverPlan(newData);
|
||||
}
|
||||
else
|
||||
{
|
||||
newData.SchemePlanId = SQLHelper.GetNewID(typeof(Model.DriverPrepare_SchemePlan));
|
||||
BLL.DriverPrepareSchemePlanService.AddDriverPrepareDriverPlan(newData);
|
||||
}
|
||||
var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(newData.SchemePlanId);
|
||||
List<string> nameLists = items.Select(x => x.SolutionName).ToList();
|
||||
string[] selectRowId = Grid1.SelectedRowIDArray;
|
||||
foreach (GridRow row in Grid1.Rows)
|
||||
{
|
||||
if (selectRowId.Contains(row.RowID) && !nameLists.Contains(row.DataKeys[1].ToString()))
|
||||
{
|
||||
Model.DriverPrepare_SchemePlanItem newItem = new Model.DriverPrepare_SchemePlanItem();
|
||||
newItem.SchemePlanItemId = SQLHelper.GetNewID();
|
||||
newItem.SchemePlanId = newData.SchemePlanId;
|
||||
newItem.SolutionName = row.DataKeys[1].ToString();
|
||||
newItem.SortIndex = row.RowIndex + 1;
|
||||
BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem);
|
||||
}
|
||||
}
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user