93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace VRS.Management.ZHC
|
||
{
|
||
public partial class Menu_Tree_Add : BasePage
|
||
{
|
||
DataService.BLL.zhc_menu_tree bll = new DataService.BLL.zhc_menu_tree();
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
protected override void Page_Load(object sender, EventArgs e)
|
||
{
|
||
base.Page_Load(sender, e);
|
||
if (!IsPostBack)
|
||
{
|
||
var parent_id = Request.Params["parent_id"];
|
||
if (string.IsNullOrEmpty(parent_id))
|
||
{
|
||
tr_parent.Visible = false;
|
||
}
|
||
else
|
||
{
|
||
tr_parent.Visible = true;
|
||
var parent = bll.GetModel(parent_id);
|
||
parent_full_name.InnerText = parent.full_name;
|
||
}
|
||
}
|
||
}
|
||
protected void btnSure_Click(object sender, EventArgs e)
|
||
{
|
||
if (string.IsNullOrEmpty(name.Text))
|
||
{
|
||
RadAjaxManager1.Alert("菜单名称不能为空!");
|
||
return;
|
||
}
|
||
|
||
int position_value = 0;
|
||
if (!int.TryParse(position.Text, out position_value))
|
||
{
|
||
RadAjaxManager1.Alert("排序号不能为空或非整数!");
|
||
return;
|
||
}
|
||
|
||
/*
|
||
if (bll.GetRecordCount(string.Format(" `name` = '{0}' and (parent_id is NULL or parent_id ='') ", name.Text.Trim())) > 0)
|
||
{
|
||
RadAjaxManager1.Alert("故障树主名称禁止重复!");
|
||
return;
|
||
}*/
|
||
|
||
var model = new DataService.Model.zhc_menu_tree();
|
||
model.id = bll.GetNewId();
|
||
model.parentId = Request.Params["parent_id"];
|
||
model.name = name.Text.Trim();
|
||
if (!string.IsNullOrEmpty(model.parentId))
|
||
{
|
||
var father = bll.GetModel(model.parentId);
|
||
model.full_id = father.full_id + "-" + model.id;
|
||
model.full_name = father.full_name+ "-" + model.name;
|
||
}
|
||
else
|
||
{
|
||
model.full_id = model.id;
|
||
model.full_name = model.name;
|
||
}
|
||
|
||
model.type = type.Text.Trim();
|
||
model.position = position_value;
|
||
model.depth = bll.GetDepth(model.parentId);
|
||
model.state = dp_state.SelectedValue;
|
||
model.info = info.Text.Trim();
|
||
|
||
model.equipment = equipment.Text.Trim();
|
||
model.component = component.Text.Trim();
|
||
model.stakeNo = stakeNo.Text.Trim();
|
||
|
||
if (bll.Add(model))
|
||
{
|
||
log.write_log("添加菜单树成功。" + "节点名称:" + name.Text.Trim() + ",节点ID:" + model.id);
|
||
RadAjaxManager1.ResponseScripts.Add("alert('添加成功!');CloseAndRebind();");
|
||
}
|
||
else
|
||
{
|
||
RadAjaxManager1.Alert("添加失败!");
|
||
|
||
}
|
||
|
||
}
|
||
}
|
||
} |