namespace erpwuliu.Depot
{
public partial class DepotAreaEdit : System.Web.UI.Page, ICallbackEventHandler
{
private string retValue = "";
protected void Page_Load(object sender, EventArgs e)
{
string strRef = Page.ClientScript.GetCallbackEventReference(this, "arg", "init", "context");
string callbackScript;
callbackScript = "function CallServer(arg, context)" + " { " + strRef + " } ;";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
if (!IsPostBack)
{
//绑定仓库信息
BindTree();
}
}
/// <summary>
/// 绑定仓位信息
/// </summary>
private void BindTree()
{
this.tvDepot.Nodes.Clear();
Depot_BLL bll = new Depot_BLL();
DataTable dt = bll.GetList("").Tables[0];
TreeNode rootNode = new TreeNode();
rootNode.Value = "-1";
rootNode.Text = "所有仓库";
rootNode.NavigateUrl = "#";
this.tvDepot.Nodes.Add(rootNode);
//绑定顶级节点
foreach (DataRow row in dt.Select(Depot_MODEL.DidFName + "=" + Depot_MODEL.DpidFName, Depot_MODEL.DidFName + " ASC"))
{
TreeNode node = new TreeNode();
node.Value = Convert.ToString(row[Depot_MODEL.DidFName]);
node.Text = "<a onClick="choiceDepot('" + node.Value + "','" + Convert.ToString(row[Depot_MODEL.DnameFName]) + "');" href="#" style="font-size: 8pt; font-family: Verdana; color: Black">" + Convert.ToString(row[Depot_MODEL.DnameFName]) + "</a>";
rootNode.ChildNodes.Add(node);
GetSubNode(ref dt, node);
}
}
/// <summary>
/// 加载子节点
/// </summary>
/// <param name="dtData">数据集</param>
/// <param name="pNode">父节点</param>
private void GetSubNode(ref DataTable dtData, TreeNode pNode)
{
foreach (DataRow row in dtData.Select(Depot_MODEL.DpidFName + "='" + pNode.Value + "' and " + Depot_MODEL.DidFName + "<>" + Depot_MODEL.DpidFName, Depot_MODEL.DidFName + " ASC"))
{
TreeNode node = new TreeNode();
node.Value = Convert.ToString(row[Depot_MODEL.DidFName]);
if (!Convert.ToBoolean(row[Depot_MODEL.IsLeafFName]))
{
node.Text = "<a onClick="choiceDepot('" + node.Value + "','" + Convert.ToString(row[Depot_MODEL.DnameFName]) + "');" href="#" style="font-size: 8pt; font-family: Verdana; color: Black">" + Convert.ToString(row[Depot_MODEL.DnameFName]) + "</a>";
}
else
{
continue;
}
node.NavigateUrl = "#";
pNode.ChildNodes.Add(node);
GetSubNode(ref dtData, node);
}
}
#region ICallbackEventHandler 成员
public string GetCallbackResult()
{
return this.retValue;
}
public void RaiseCallbackEvent(string eventArgument)
{
string[] args = eventArgument.Split('|');
Depot_BLL bll = new Depot_BLL();
Hashtable hsData = new Hashtable();
if (args[6] == "add")
{
if (!String.IsNullOrEmpty(args[1]))
{
bll.Delete(args[1]);
}
//保存仓位信息
hsData[Depot_MODEL.DidFName] = bll.GetNextId();
hsData[Depot_MODEL.DpidFName] = args[0];
hsData[Depot_MODEL.DnameFName] = args[2];
hsData[Depot_MODEL.DtypeFName] = args[3];
hsData[Depot_MODEL.DlonFName] = args[4];
hsData[Depot_MODEL.DlatFName] = args[5];
hsData[Depot_MODEL.IsLeafFName] = true;
if (bll.Add(hsData))
{
this.retValue = Convert.ToString(hsData[Depot_MODEL.DidFName]) + "|add";
}
else
{
this.retValue = "|add";
}
}
else if (args[6] == "get")
{
DataTable dtTemp = bll.GetList(Depot_MODEL.DidFName + "='" + args[1] + "'").Tables[0];
if (dtTemp.Rows.Count > 0)
{
this.retValue = Convert.ToString(dtTemp.Rows[0][Depot_MODEL.DnameFName]);
string[] strTemp = Convert.ToString(dtTemp.Rows[0][Depot_MODEL.DtypeFName]).Split(',');
retValue += "|" + strTemp[0];//长
retValue += "|" + strTemp[1];//宽
retValue += "|" + strTemp[2];//高
retValue += "|" + strTemp[3];//类型
retValue += "|get";
}
}
else if (args[6] == "delete")
{
DepotAreaInfo_BLL dBll = new DepotAreaInfo_BLL();
if (dBll.GetList(DepotAreaInfo_MODEL.DidFName + "='" + args[1] + "'").Tables[0].Rows.Count > 0)
{
this.retValue = "error|delete";
}
else
{
bll.Delete(args[1]);
this.retValue = "ok|delete";
}
}
else if (args[6] == "getList")
{
DataTable dtTemp = bll.GetList(Depot_MODEL.DpidFName + "='" + args[0] + "' and " + Depot_MODEL.IsLeafFName + "=1 and " + Depot_MODEL.DidFName + "<>" + args[0]).Tables[0];
foreach (DataRow row in dtTemp.Rows)
{
this.retValue += Convert.ToString(row[Depot_MODEL.DidFName]);
this.retValue += "|" + Convert.ToString(row[Depot_MODEL.DnameFName]);
this.retValue += "|" + Convert.ToString(row[Depot_MODEL.DtypeFName]);
this.retValue += "|" + Convert.ToString(row[Depot_MODEL.DlonFName]);
this.retValue += "|" + Convert.ToString(row[Depot_MODEL.DlatFName]);
this.retValue += "@";
}
this.retValue += "|getList";
}
else
{
if (bll.UpdatePostion(args[1], Convert.ToInt32(args[4]), Convert.ToInt32(args[5])))
{
this.retValue = "ok|update";
}
}
}
#endregion
}
}
{
public partial class DepotAreaEdit : System.Web.UI.Page, ICallbackEventHandler
{
private string retValue = "";
protected void Page_Load(object sender, EventArgs e)
{
string strRef = Page.ClientScript.GetCallbackEventReference(this, "arg", "init", "context");
string callbackScript;
callbackScript = "function CallServer(arg, context)" + " { " + strRef + " } ;";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
if (!IsPostBack)
{
//绑定仓库信息
BindTree();
}
}
/// <summary>
/// 绑定仓位信息
/// </summary>
private void BindTree()
{
this.tvDepot.Nodes.Clear();
Depot_BLL bll = new Depot_BLL();
DataTable dt = bll.GetList("").Tables[0];
TreeNode rootNode = new TreeNode();
rootNode.Value = "-1";
rootNode.Text = "所有仓库";
rootNode.NavigateUrl = "#";
this.tvDepot.Nodes.Add(rootNode);
//绑定顶级节点
foreach (DataRow row in dt.Select(Depot_MODEL.DidFName + "=" + Depot_MODEL.DpidFName, Depot_MODEL.DidFName + " ASC"))
{
TreeNode node = new TreeNode();
node.Value = Convert.ToString(row[Depot_MODEL.DidFName]);
node.Text = "<a onClick="choiceDepot('" + node.Value + "','" + Convert.ToString(row[Depot_MODEL.DnameFName]) + "');" href="#" style="font-size: 8pt; font-family: Verdana; color: Black">" + Convert.ToString(row[Depot_MODEL.DnameFName]) + "</a>";
rootNode.ChildNodes.Add(node);
GetSubNode(ref dt, node);
}
}
/// <summary>
/// 加载子节点
/// </summary>
/// <param name="dtData">数据集</param>
/// <param name="pNode">父节点</param>
private void GetSubNode(ref DataTable dtData, TreeNode pNode)
{
foreach (DataRow row in dtData.Select(Depot_MODEL.DpidFName + "='" + pNode.Value + "' and " + Depot_MODEL.DidFName + "<>" + Depot_MODEL.DpidFName, Depot_MODEL.DidFName + " ASC"))
{
TreeNode node = new TreeNode();
node.Value = Convert.ToString(row[Depot_MODEL.DidFName]);
if (!Convert.ToBoolean(row[Depot_MODEL.IsLeafFName]))
{
node.Text = "<a onClick="choiceDepot('" + node.Value + "','" + Convert.ToString(row[Depot_MODEL.DnameFName]) + "');" href="#" style="font-size: 8pt; font-family: Verdana; color: Black">" + Convert.ToString(row[Depot_MODEL.DnameFName]) + "</a>";
}
else
{
continue;
}
node.NavigateUrl = "#";
pNode.ChildNodes.Add(node);
GetSubNode(ref dtData, node);
}
}
#region ICallbackEventHandler 成员
public string GetCallbackResult()
{
return this.retValue;
}
public void RaiseCallbackEvent(string eventArgument)
{
string[] args = eventArgument.Split('|');
Depot_BLL bll = new Depot_BLL();
Hashtable hsData = new Hashtable();
if (args[6] == "add")
{
if (!String.IsNullOrEmpty(args[1]))
{
bll.Delete(args[1]);
}
//保存仓位信息
hsData[Depot_MODEL.DidFName] = bll.GetNextId();
hsData[Depot_MODEL.DpidFName] = args[0];
hsData[Depot_MODEL.DnameFName] = args[2];
hsData[Depot_MODEL.DtypeFName] = args[3];
hsData[Depot_MODEL.DlonFName] = args[4];
hsData[Depot_MODEL.DlatFName] = args[5];
hsData[Depot_MODEL.IsLeafFName] = true;
if (bll.Add(hsData))
{
this.retValue = Convert.ToString(hsData[Depot_MODEL.DidFName]) + "|add";
}
else
{
this.retValue = "|add";
}
}
else if (args[6] == "get")
{
DataTable dtTemp = bll.GetList(Depot_MODEL.DidFName + "='" + args[1] + "'").Tables[0];
if (dtTemp.Rows.Count > 0)
{
this.retValue = Convert.ToString(dtTemp.Rows[0][Depot_MODEL.DnameFName]);
string[] strTemp = Convert.ToString(dtTemp.Rows[0][Depot_MODEL.DtypeFName]).Split(',');
retValue += "|" + strTemp[0];//长
retValue += "|" + strTemp[1];//宽
retValue += "|" + strTemp[2];//高
retValue += "|" + strTemp[3];//类型
retValue += "|get";
}
}
else if (args[6] == "delete")
{
DepotAreaInfo_BLL dBll = new DepotAreaInfo_BLL();
if (dBll.GetList(DepotAreaInfo_MODEL.DidFName + "='" + args[1] + "'").Tables[0].Rows.Count > 0)
{
this.retValue = "error|delete";
}
else
{
bll.Delete(args[1]);
this.retValue = "ok|delete";
}
}
else if (args[6] == "getList")
{
DataTable dtTemp = bll.GetList(Depot_MODEL.DpidFName + "='" + args[0] + "' and " + Depot_MODEL.IsLeafFName + "=1 and " + Depot_MODEL.DidFName + "<>" + args[0]).Tables[0];
foreach (DataRow row in dtTemp.Rows)
{
this.retValue += Convert.ToString(row[Depot_MODEL.DidFName]);
this.retValue += "|" + Convert.ToString(row[Depot_MODEL.DnameFName]);
this.retValue += "|" + Convert.ToString(row[Depot_MODEL.DtypeFName]);
this.retValue += "|" + Convert.ToString(row[Depot_MODEL.DlonFName]);
this.retValue += "|" + Convert.ToString(row[Depot_MODEL.DlatFName]);
this.retValue += "@";
}
this.retValue += "|getList";
}
else
{
if (bll.UpdatePostion(args[1], Convert.ToInt32(args[4]), Convert.ToInt32(args[5])))
{
this.retValue = "ok|update";
}
}
}
#endregion
}
}