根据类型编号获取父类名称

-- =============================================
CREATE FUNCTION [dbo].[FN_getParentTypeNameByTypeID]
(
@TypeID INT
)
RETURNS NVARCHAR(100)
AS
BEGIN
DECLARE @parentTypename NVARCHAR(100)
SELECT @parentTypename=TypeName FROM BioProType
WHERE TypeID=(SELECT ParentTypeID FROM dbo.BioProType WHERE
TypeID=@TypeID) RETURN @parentTypename
END

1.管理页面实现产品类型列表显示(分页)。

前端的代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProTypeListShow.aspx.cs" Inherits="BioErpWeb.WholeSaleSystem.Product.ProTypeListShow" %>
<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="../../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
<link href="../../Styles/AspNetPagerStyle.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="../../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>
<script src="../../Scripts/validateExtender.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.metadata.js" type="text/javascript"></script>
<script src="../../JS/ProTypeChoose.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function () {
$("#form1").validate();
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<table class="maintable">
<tr>
<td colspan="2" class="titlebar">
<span>产品类型管理</span>
</td>
</tr>
<tr>
<td class="tdsearch">
<asp:Label ID="Label1" runat="server" Text="类型名称:"></asp:Label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td> <td class="tdsearch" style=" text-align:right; padding-right:20px;">
<asp:ImageButton ID="imgbutnSearch" Width="60" Height="22" runat="server"
ImageUrl="~/Web/images/Btnsearch.gif" onclick="imgbutnSearch_Click" /> 
<asp:ImageButton ID="imgbtnNew" runat="server" Width="60" Height="22"
ImageUrl="~/Web/images/btnadd.gif" onclick="imgbtnNew_Click"/>
</td>
</tr>
<tr>
<td colspan="2" class="bottomtd"> <asp:GridView ID="GridView1" Width="100%" runat="server" AutoGenerateColumns="False" DataKeyNames="TypeID"
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField HeaderText="类型编号" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("TypeID") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="类型名称" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Eval("TypeName") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="父类编号" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("ParentTypeID") %>'></asp:Label>
</ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="父类名称" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lp" runat="server" Text='<%# Eval("parentTypeName") %>'></asp:Label>
</ItemTemplate> <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField> <asp:TemplateField HeaderText="操作" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:ImageButton ID="imgE" CommandName="ImgEdit" CommandArgument='<%#Eval("TypeID") %>' runat="server" ImageUrl="~/Web/images/Edit.gif" Width="50" Height="20"/>
<asp:ImageButton ID="imgDel" CommandName="ImgDelete" OnClientClick="return confirm('确定删除?');" CommandArgument='<%#Eval("TypeID") %>' runat="server" ImageUrl="~/Web/images/Delete.gif" Width="50" Height="20"/>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="120px" />
</asp:TemplateField> </Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td> <webdiyer:AspNetPager ID="AspNetPager1" CssClass="paginator"
CurrentPageButtonClass="cpb" runat="server"
onpagechanged="AspNetPager1_PageChanged1">
</webdiyer:AspNetPager>
</td>
</tr> </table>
</div> <div>
<table class="maintable">
<tr>
<td colspan="2" class="titlebar">
产品类型修改
</td>
</tr>
<tr>
<td class="style1">
类型名称
</td>
<td class="style1">
<asp:TextBox ID="txtTypeName" CssClass="{required:true}" runat="server" ></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
所属大类</td>
<td class="style1">
<asp:TextBox ID="txtSupertTypeID"
CssClass="{required:true, number:true, min:0}" runat="server"
></asp:TextBox><input type="button" value="选择" onclick="showProType()"/> <asp:Label ID="Label2" runat="server" ForeColor="Red" Text="(注:如果为0代表顶级父类)"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2" class="bottomtd">
<asp:Button ID="btnSubmit" runat="server" Text="产品类型保存"
onclick="btnSubmit_Click" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>

删除节点的通用方法:

  /// <summary>
/// 删除指定表 父级节点下面的所有子节点。
/// </summary>
/// <param name="tableName">表名</param>
/// <param name="ParentNodeID">编号</param>
public static void deleteParentNode(string NodeID)
{
//DataTable dt = "select id from table where upid=" + id;
DataTable dt = SqlComm.GetDataByCondition("BioProType", "TypeID", " ParentTypeID=" + NodeID).Tables[0];
//存在子级的
if(dt.Rows.Count>0)
{
foreach (DataRow aRow in dt.Rows)
{
//递归搜索子级
deleteParentNode(aRow["TypeID"].ToString());
}
//删除子节点后再删除当前节点。
SqlComm.DeleteTableByCondition("BioProType", " where TypeID=" + NodeID);
}
//删除不存在的
else
{
SqlComm.DeleteTableByCondition("BioProType", " where TypeID=" + NodeID);
}
}

后台代码:

 public static int pageindex = 0;
public static int pagesize = 10;
public static string condition = ""; protected void Page_Load(object sender, EventArgs e)
{
////Session["Userid"] = "29"; if (!IsPostBack)
{
getallPageList();
}
} /// <summary>
/// 查询所有联系人信息
/// </summary>
private void getallPageList()
{
this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.BioProType", condition);
this.AspNetPager1.PageSize = pagesize;
this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.BioProType", "*,parentTypeName=dbo.FN_getParentTypeNameByTypeID(TypeID)", "TypeID", condition, pageindex, pagesize);
this.GridView1.DataBind();
} protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
pageindex = this.AspNetPager1.CurrentPageIndex - 1;
getallPageList();
} protected void imgbutnSearch_Click(object sender, ImageClickEventArgs e)
{
pageindex = 0;
condition = "";
if (txtName.Text.Trim() != null && this.txtName.Text.Trim().Length != 0)
{
condition = condition + " and TypeName like '" + txtName.Text + "%'";
} getallPageList(); } protected void imgbtnNew_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("ProTypeInsert.aspx");
}
BioProType type = null;
static string id = "";
protected void btnSubmit_Click(object sender, EventArgs e)
{
//if (type == null)
//{
// ScriptManager.RegisterStartupScript(this, this.GetType(), "teet", "alert('请选择类型后再修改')", true);
// return;
//}
BioProType type = new BioProType();
type.TypeID = int.Parse(id);
type.TypeName =this.txtTypeName.Text;
type.ParentTypeID =int.Parse(this.txtSupertTypeID.Text);
BioProTypeBLL typebll = new BioProTypeBLL();
if (typebll.ProTypeUpdate(type) != 0)
{
getallPageList();
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "teet", "alert('修改不成功')", true); }
} protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
BioProTypeBLL typebll = new BioProTypeBLL();
type = new BioProType();
if (e.CommandName == "ImgEdit")
{
id = e.CommandArgument.ToString();
type = typebll.getProTypeByTypeID(id);
this.txtTypeName.Text = type.TypeName;
this.txtSupertTypeID.Text = type.ParentTypeID.ToString(); } if (e.CommandName == "ImgDelete")
{
string Typeid = e.CommandArgument.ToString();
SqlComm.deleteParentNode(Typeid);
getallPageList(); }
}
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void AspNetPager1_PageChanged1(object sender, EventArgs e)
{
pageindex = this.AspNetPager1.CurrentPageIndex - 1;
getallPageList();
}

ERP商品类型管理相关业务处理(三十五)的更多相关文章

  1. 孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容

     孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.打开文件后,要务必记得关闭,所以一般的写法应当 ...

  2. Python进阶(三十五)-Fiddler命令行和HTTP断点调试

    Python进阶(三十五)-Fiddler命令行和HTTP断点调试 一. Fiddler内置命令   上一节(使用Fiddler进行抓包分析)中,介绍到,在web session(与我们通常所说的se ...

  3. 风炫安全web安全学习第三十五节课 文件下载和文件读取漏洞

    风炫安全web安全学习第三十五节课 文件下载和文件读取漏洞 0x03 任意文件下载漏洞 一些网站由于业务需求,往往需要提供文件下载功能,但若对用户下载的文件不做限制,则恶意用户就能够下载任意敏感文件, ...

  4. 程序员与年龄:四十岁普通开发、三十五岁首席架构、三十岁基层Leader

    最近,有一个词儿特别热门--躺平.有没有人跟你说过:"躺平说起来容易,做起来更容易." 和躺平相对的是另外一个词--内卷,群聊的时候,已经很多次看过草卷起来了.jpg表情包.某些节 ...

  5. NeHe OpenGL教程 第三十五课:播放AVI

    转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...

  6. Java进阶(三十五)java int与integer的区别

    Java进阶(三十五)java int与Integer的区别 前言 int与Integer的区别从大的方面来说就是基本数据类型与其包装类的区别: int 是基本类型,直接存数值,而Integer是对象 ...

  7. Gradle 1.12用户指南翻译——第三十五章. Sonar 插件

    本文由CSDN博客万一博主翻译,其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Githu ...

  8. 第三百三十五节,web爬虫讲解2—Scrapy框架爬虫—豆瓣登录与利用打码接口实现自动识别验证码

    第三百三十五节,web爬虫讲解2—Scrapy框架爬虫—豆瓣登录与利用打码接口实现自动识别验证码 打码接口文件 # -*- coding: cp936 -*- import sys import os ...

  9. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

随机推荐

  1. python---tornado初识(2)实现登录和发布文章

    # coding:utf8 # __author: Administrator # date: 2018/3/6 0006 # /usr/bin/env python import tornado.i ...

  2. Syncfusion HTMLUI研究一

    HTMLUI可以加载HTML页面,并且相比WebKit等占用资源特别少 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitiona ...

  3. Dojo与jQuery综合比较分析

    最近一直都在参与项目,无法抽空写些或者看些东西,周末抽了点时间看了下关于Dojo和Jquery的东西,在CSDN上看到一篇两个框架进行对比的文章,感觉写的不错,就拿了过来,没有别的意思,一来想保留下来 ...

  4. ssh 登录出现Are you sure you want to continue connecting (yes/no)?解决方法

    ssh 登录出现Are you sure you want to continue connecting (yes/no)?解决方法 1,可以使用ssh -o 的参数进行设置例如: ssh -o St ...

  5. 无线路由器的web漏洞

    1.XSS漏洞 2.CSRF漏洞 这样的攻击方式具体可以由多种形式实现,除了建立欺诈服务器外,还可以使用超链接陷阱.所谓的超链接陷阱,就是指伪造一个可信的链接或者地址,但其实际地址中包含了修改无线路由 ...

  6. 20155333 2016-2017-2 《Java程序设计》第六周学习总结

    20155333 2016-2017-2 <Java程序设计>第六周学习总结 教材学习内容总结 流(Stream)是对「输入输出」的抽象,注意「输入输出」是相对程序而言的 InputStr ...

  7. HDU 2522 A simple problem (模拟)

    题目链接 Problem Description Zty很痴迷数学问题..一天,yifenfei出了个数学题想难倒他,让他回答1 / n.但Zty却回答不了^_^. 请大家编程帮助他. Input 第 ...

  8. 设置PHPStorm 注释

    /** * Desc: xxx#if (${NAME}) * Class: ${NAME}#end#if (${NAMESPACE}) * Package: ${NAMESPACE}#end * Us ...

  9. python - class类 (一)

    三大编程范式 1.面向过程 2.函数式 3.面向对象 注意 编程范式没有高低之分,只有适用不适用. 面向对象编程: 编程是程序源用特定的语法+数据结构+算法组成的代码来告诉计算机如何执行任务的过程,一 ...

  10. OKVIS 代码框架

    1. okvis_app_synchronous.cpp 在此文件中 okvis 对象为 okvis_estimator,是类 okvis::ThreadedKFVio 的实例化对象. 数据输入接口是 ...