102 lines
4.8 KiB
C#
102 lines
4.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.TestRun.DriverPrepare
|
|
{
|
|
public partial class SchemePlanItemAdd : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
string SchemePlanItemId = Request.Params["SchemePlanItemId"];
|
|
if (!string.IsNullOrEmpty(SchemePlanItemId))
|
|
{
|
|
Model.DriverPrepare_SchemePlanItem item = DriverPrepareSchemePlanItemService.GetSchemePlanItemById(SchemePlanItemId);
|
|
if (item != null)
|
|
{
|
|
this.txtSolutionName.Text = item.SolutionName;
|
|
this.txtSolutionType.Text = item.SolutionType;
|
|
}
|
|
}
|
|
var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan
|
|
join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId
|
|
where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId
|
|
select y).FirstOrDefault();
|
|
if (solutionType != null)
|
|
{
|
|
this.txtSolutionType.Hidden = false;
|
|
}
|
|
else
|
|
{
|
|
this.txtSolutionType.Hidden = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
string SchemePlanItemId = Request.Params["SchemePlanItemId"];
|
|
if (!BLL.DriverPrepareSchemePlanItemService.IsExistSolutionName(this.CurrUser.LoginProjectId, this.txtSolutionName.Text.Trim(), SchemePlanItemId))
|
|
{
|
|
Model.DriverPrepare_SchemePlanItem newItem = new Model.DriverPrepare_SchemePlanItem();
|
|
newItem.SolutionName = this.txtSolutionName.Text.Trim();
|
|
Model.DriverPrepare_SchemePlan plan = BLL.DriverPrepareSchemePlanService.GetDriverPlanByProjectId(this.CurrUser.LoginProjectId);
|
|
int sortIndex = 200;
|
|
if (plan != null)
|
|
{
|
|
var items = BLL.DriverPrepareSchemePlanItemService.GetSchemePlanItemByschemePlanId(plan.SchemePlanId);
|
|
sortIndex += items.Count;
|
|
newItem.SchemePlanId = plan.SchemePlanId;
|
|
}
|
|
else
|
|
{
|
|
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;
|
|
newData.SchemePlanId = SQLHelper.GetNewID(typeof(Model.DriverPrepare_SchemePlan));
|
|
BLL.DriverPrepareSchemePlanService.AddDriverPrepareDriverPlan(newData);
|
|
newItem.SchemePlanId = newData.SchemePlanId;
|
|
}
|
|
newItem.SortIndex = sortIndex;
|
|
var solutionType = (from x in Funs.DB.DriverPrepare_SchemePlan
|
|
join y in Funs.DB.DriverPrepare_SchemePlanItem on x.SchemePlanId equals y.SchemePlanId
|
|
where y.SolutionType != null && x.ProjectId == this.CurrUser.LoginProjectId
|
|
select y).FirstOrDefault();
|
|
if (solutionType != null)
|
|
{
|
|
newItem.SolutionType = this.txtSolutionType.Text.Trim();
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
if (string.IsNullOrEmpty(SchemePlanItemId))
|
|
{
|
|
newItem.SchemePlanItemId = SQLHelper.GetNewID();
|
|
BLL.DriverPrepareSchemePlanItemService.AddSchemePlanItem(newItem);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, newItem.SolutionName, newItem.SolutionName, BLL.Const.ControlItemInitSetMenuId, "增加开车方案!");
|
|
}
|
|
else
|
|
{
|
|
newItem.SchemePlanItemId = SchemePlanItemId;
|
|
BLL.DriverPrepareSchemePlanItemService.UpdateSchemePlanItem(newItem);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, newItem.SolutionName, newItem.SolutionName, BLL.Const.ControlItemInitSetMenuId, "修改开车方案!");
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("此方案已存在!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
}
|
|
} |