CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/TestRun/DriverSub/DriverSubEdit.aspx.cs

195 lines
7.0 KiB
C#
Raw Normal View History

2024-01-25 15:21:19 +08:00
using BLL;
2024-02-04 11:12:50 +08:00
using Newtonsoft.Json.Linq;
2024-01-25 15:21:19 +08:00
using System;
2024-02-04 11:12:50 +08:00
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
2024-01-25 15:21:19 +08:00
namespace FineUIPro.Web.TestRun.DriverSub
{
public partial class DriverSubEdit :PageBase
{
2024-02-04 11:12:50 +08:00
public string DriverSubPlanId {
get
{
return (string)ViewState["DriverSubPlanId"];
}
set
{
ViewState["DriverSubPlanId"] = value;
}
}
public string DriverSubId
{
get
{
return (string)ViewState["DriverSubId"];
}
set
{
ViewState["DriverSubId"] = value;
}
}
2024-01-25 15:21:19 +08:00
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
2024-02-04 11:12:50 +08:00
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
DriverSubPlanId = Request.Params["DriverSubPlanId"];
if (!string.IsNullOrEmpty(DriverSubPlanId))
2024-01-25 15:21:19 +08:00
{
2024-02-04 11:12:50 +08:00
InitTreeMenu();
2024-01-25 15:21:19 +08:00
}
}
}
#endregion
2024-02-04 11:12:50 +08:00
void InitTreeMenu()
{
this.tvControlItem.Nodes.Clear();
var subPlanModel= DriverSubPlanService.GetDriverSubPlanById(DriverSubPlanId);
if (subPlanModel != null)
{
2024-02-19 10:32:15 +08:00
foreach (var item in subPlanModel.SubcontractingTypes.Split(','))
2024-02-04 11:12:50 +08:00
{
var name = DropListService.drpDriverSubNameList().Where(x => x.Value == item) .First().Text;
FineUIPro.TreeNode node = new FineUIPro.TreeNode();
node.NodeID = item;
node.Text = name;
node.CommandName = name;
node.Expanded = true;
this.tvControlItem.Nodes.Add(node);
BindNode(node, item);
}
}
}
void BindNode(TreeNode node,string type )
{
var SubContractorsList= DriverSubContactService.GetDriverSubContactByDriverSubPlanId(DriverSubPlanId)
2024-02-19 10:32:15 +08:00
.Where(x => x.SubcontractingType == type && x.IsBidirectional==true).Select(x => x.DriverSubContractorsId).ToArray();
2024-02-04 11:12:50 +08:00
foreach (var item in SubContractorsList)
{
string unitName= BLL.DriversubcontractorsService.GetDriverSub_DriverSubContractorsById(item).SubUnitName;
FineUIPro.TreeNode node1 = new FineUIPro.TreeNode();
node1.NodeID = item;
node1.Text = unitName;
2024-02-19 10:32:15 +08:00
node1.CommandName = type;
2024-02-04 11:12:50 +08:00
node1.EnableClickEvent=true;
node.Nodes.Add(node1);
}
}
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
{
var list= BLL.DriverSubService.GetDriverSubEvaluationData(DriverSubPlanId, tvControlItem.SelectedNodeID);
var model= BLL.DriverSubService.GetDriverSubBySubPlanIdAndTractorsId(DriverSubPlanId,tvControlItem.SelectedNodeID);
if (model!=null)
{
DriverSubId = model.DriverSubId;
2024-02-21 15:13:54 +08:00
txtDriverContractCode.Text = model.DriverContractCode;
txtSubContractName.Text = model.SubContractName;
txtEvaluator.Text = model.Evaluator;
2024-02-04 11:12:50 +08:00
}
else
{
DriverSubId = "";
}
if (list.Count>0 )
{
Grid1.DataSource = list;
Grid1.DataBind();
}
else
{
2024-02-19 10:32:15 +08:00
Grid1.DataSource = BLL.DriverSubService.GetDriverSubEvaluationData(tvControlItem.SelectedNode.CommandName);
2024-02-04 11:12:50 +08:00
Grid1.DataBind();
}
}
2024-01-25 15:21:19 +08:00
#region
/// <summary>
/// 附件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach_Click(object sender, EventArgs e)
{
2024-02-04 11:12:50 +08:00
Save();
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverSub/DriverSub&menuId={1}", DriverSubId, BLL.Const.DriverSubMenuId)));
2024-01-25 15:21:19 +08:00
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
2024-02-04 11:12:50 +08:00
Save();
tvControlItem_NodeCommand(null,null);
ShowNotify("保存成功!", MessageBoxIcon.Success);
// PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
void Save()
{
JArray EditorArr = Grid1.GetMergedData();
//JArray 转换成List<Model.DriverSubEvaluationData>
List<Model.DriverSubEvaluationData> list = new List<Model.DriverSubEvaluationData>();
foreach (JObject item in EditorArr)
2024-01-25 15:21:19 +08:00
{
2024-02-04 11:12:50 +08:00
Model.DriverSubEvaluationData data = new Model.DriverSubEvaluationData();
data.Number = Convert.ToInt32(item["values"]["Number"]);
data.Matter = item["values"]["Matter"].ToString();
data.Grade = item["values"]["Grade"].ToString();
list.Add(data);
2024-01-25 15:21:19 +08:00
}
2024-02-04 11:12:50 +08:00
//list转换成json数据
string json = BLL.DriverSubService.GetDriverSubEvaluationDataJson(list);
2024-01-25 15:21:19 +08:00
Model.DriverSub_DriverSub newData = new Model.DriverSub_DriverSub();
newData.ProjectId = this.CurrUser.LoginProjectId;
2024-02-04 11:12:50 +08:00
newData.DriverSubPlanId = DriverSubPlanId;
newData.DriverSubContractorsId = tvControlItem.SelectedNodeID;
newData.EvaluationData = json;
2024-02-21 15:13:54 +08:00
newData.DriverContractCode = txtDriverContractCode.Text;
newData.SubContractName = txtSubContractName.Text;
newData.Evaluator = txtEvaluator.Text;
2024-02-04 11:12:50 +08:00
if (string.IsNullOrEmpty(DriverSubId))
2024-01-25 15:21:19 +08:00
{
2024-02-04 11:12:50 +08:00
newData.DriverSubId = SQLHelper.GetNewID(typeof(Model.DriverSub_DriverSub));
DriverSubId= newData.DriverSubId;
DriverSubService.AddDriverSub(newData);
2024-01-25 15:21:19 +08:00
}
else
{
2024-02-04 11:12:50 +08:00
newData.DriverSubId = DriverSubId;
DriverSubService.UpdateDriverSub(newData);
2024-01-25 15:21:19 +08:00
}
2024-02-04 11:12:50 +08:00
2024-01-25 15:21:19 +08:00
}
2024-02-04 11:12:50 +08:00
2024-01-25 15:21:19 +08:00
#endregion
2024-02-04 11:12:50 +08:00
2024-02-21 15:13:54 +08:00
protected void btnOut_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(DriverSubId))
{
ShowNotify("请先编辑数据!", MessageBoxIcon.Success);
return;
}
BLL.DriverSubService.PrintFile(DriverSubPlanId, tvControlItem.SelectedNodeID);
}
2024-01-25 15:21:19 +08:00
}
}