gyhlw_dotnet/网站项目/VRS/Management/ZHC/Fault_Tree_Add.aspx.cs

114 lines
4.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 Fault_Tree_Add : BasePage
{
DataService.BLL.zhc_fault_tree bll = new DataService.BLL.zhc_fault_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;
tr_fault.Visible = true;
title.Text = "添加故障树";
span_name.InnerText = "故障树名称";
}
else
{
tr_parent.Visible = true;
tr_fault.Visible = false;
var parent = bll.GetModel(parent_id);
title.Text = "添加子节点";
span_name.InnerText = "节点名称";
parent_full_name.InnerText = parent.full_name;
}
BindDeviceType("7", dp_logic, "");
BindFaultList(dp_fault_list, "");
}
}
protected void btnSure_Click(object sender, EventArgs e)
{
var parent_id = Request.Params["parent_id"];
if (string.IsNullOrEmpty(dp_fault_list.SelectedValue) && string.IsNullOrEmpty(parent_id))
{
RadAjaxManager1.Alert("故障列表不能为空!");
return;
}
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;
}
DataService.Model.zhc_fault_tree model = new DataService.Model.zhc_fault_tree();
model.tree_id = bll.GetNewId();
model.name = name.Text.Trim();
model.dsc = dsc.Text.Trim();
model.code = "0";
model.position = position_value;
model.parent_id = parent_id;
if (!string.IsNullOrEmpty(model.parent_id))
{
var father = bll.GetModel(model.parent_id);
model.full_id = father.full_id + "-" + model.tree_id;
model.full_name = father.full_name + "-" + model.name;
}
else
{
model.full_id = model.tree_id;
model.full_name = model.name;
}
model.logic_gate = dp_logic.SelectedValue;
if (string.IsNullOrEmpty(parent_id))
{
model.fault_list_id = dp_fault_list.SelectedValue;
}
else
{
var model_parent = bll.GetModel(parent_id);
if (null != model_parent)
{
model.fault_list_id = model_parent.fault_list_id;
}
}
model.state = int.Parse(dp_state.SelectedValue);
if (bll.Add(model))
{
log.write_log("添加故障树成功。" + "故障节点名称:" + name.Text.Trim() + "节点ID" + model.tree_id);
RadAjaxManager1.ResponseScripts.Add("alert('添加成功!');CloseAndRebind();");
}
else
{
RadAjaxManager1.Alert("添加失败!");
}
}
}
}