TreeGrid-无限制树形GUCD (五)

2014-11-24 01:35:52 · 作者: · 浏览: 10
= name;
menu.Pid = pid;
bool bl = false;
string sql = "";
if (txtType.Text == "add")
{
sql = "insert into [CustomerSource] (Name,ParentId) values ('" + menu.Name + "'," + menu.Pid + ")";
int res = DbHelperSQL.ExecuteSql(sql, null);
if (res > 0)
bl = true;
}
else
{
string[] strValue = txtValue.Text.Split('|');
menu.Id = strValue[0];
sql = "update CustomerSource set Name='" + menu.Name + "' " + " where Id=" + menu.Id + " ";
int res = DbHelperSQL.ExecuteSql(sql, null);
if (res > 0)
bl = true;
}
if (bl)
{
txt_Menu_Name_varchar2.Text = "";

Notification.Show(new NotificationConfig
{
Title = "客户来源管理",
Icon = Icon.Information,
Html = "保存成功"
});




winMenuAdd.Hide();
string rtn = RefreshMenu();
return rtn;

}
else
{

Notification.Show(new NotificationConfig
{
Title = "客户来源管理",
Icon = Icon.Information,
Html = "保存失败"
});
return this.TreeGrid1.Root.ToJson();
}
this.txtValue.Text = "";
}
///
/// 删除
///

///
[DirectMethod]
public string Delete()
{
string[] strValue = txtValue.Text.Split('|');
string id = strValue[0];
string ssql = "select Id from [CustomerSource] where ParentId=" + id + "";
DataTable dt = DbHelperSQL.ExecuteDT(ssql, null);
if (dt.Rows.Count > 0)
{

Notification.Show(new NotificationConfig
{
Title = "客户来源管理",
Icon = Icon.Information,
Html = "存在根节点,请先删除下级!"
});

}
else
{
string sql = "delete from CustomerSource where Id=" + id + "";
int res = DbHelperSQL.ExecuteSql(sql, null);
bool success = false;
if (res > 0)
success = true;
if (success)
{

Notification.Show(new NotificationConfig
{
Title = "客户来源管理",
Icon = Icon.Information,
Html = "删除成功"
});

}
else
{

Notification.Show(new NotificationConfig
{
Title = "客户来源管理",
Icon = Icon.Information,
Html = "删除失败"
});

}

this.txtValue.Text = "";
}
return RefreshMenu();
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
us