ERP商品类型管理相关业务处理(三十五)
根据类型编号获取父类名称
-- =============================================
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商品类型管理相关业务处理(三十五)的更多相关文章
- 孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容
孤荷凌寒自学python第三十五天python的文件操作之针对文件操作的os模块的相关内容 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 一.打开文件后,要务必记得关闭,所以一般的写法应当 ...
- Python进阶(三十五)-Fiddler命令行和HTTP断点调试
Python进阶(三十五)-Fiddler命令行和HTTP断点调试 一. Fiddler内置命令 上一节(使用Fiddler进行抓包分析)中,介绍到,在web session(与我们通常所说的se ...
- 风炫安全web安全学习第三十五节课 文件下载和文件读取漏洞
风炫安全web安全学习第三十五节课 文件下载和文件读取漏洞 0x03 任意文件下载漏洞 一些网站由于业务需求,往往需要提供文件下载功能,但若对用户下载的文件不做限制,则恶意用户就能够下载任意敏感文件, ...
- 程序员与年龄:四十岁普通开发、三十五岁首席架构、三十岁基层Leader
最近,有一个词儿特别热门--躺平.有没有人跟你说过:"躺平说起来容易,做起来更容易." 和躺平相对的是另外一个词--内卷,群聊的时候,已经很多次看过草卷起来了.jpg表情包.某些节 ...
- NeHe OpenGL教程 第三十五课:播放AVI
转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...
- Java进阶(三十五)java int与integer的区别
Java进阶(三十五)java int与Integer的区别 前言 int与Integer的区别从大的方面来说就是基本数据类型与其包装类的区别: int 是基本类型,直接存数值,而Integer是对象 ...
- Gradle 1.12用户指南翻译——第三十五章. Sonar 插件
本文由CSDN博客万一博主翻译,其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Githu ...
- 第三百三十五节,web爬虫讲解2—Scrapy框架爬虫—豆瓣登录与利用打码接口实现自动识别验证码
第三百三十五节,web爬虫讲解2—Scrapy框架爬虫—豆瓣登录与利用打码接口实现自动识别验证码 打码接口文件 # -*- coding: cp936 -*- import sys import os ...
- centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课
centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件.目录属性 shell数组简单用法 $( ) 和$ ...
随机推荐
- springboot环境下配置过滤器和拦截器
以前我们在配置过滤器和拦截器的时候,都是一个类继承一个接口,然后在xml中配置一下就ok 但是,但是,这是springboot的环境,没有xml的配置.所以我们还要继续学习啊啊啊啊啊~~~~~ 先简单 ...
- secure CRT the remote system refused the connection 解决办法
1.安装ssh服务器和客户端 apt-get install openssh-server apt-get install openssh-client 2.重启ssh /etc/init.d/ssh ...
- VUE2.0 饿了吗视频学习笔记(四):颜色、跳转、设置、vue-resource
https://gitee.com/1981633/vue_study.git 源码下载地址,随笔记动态更新中 1.设置选中项颜色 <template> <div id=" ...
- C#复杂类型序列化
[Serializable] public class CardItemInfo { private int lineWidth;//线宽 private CardItemInfo childCard ...
- C# 使用ffmpeg视频截图
<appSettings> <add key="ffmpeg" value="E:\ffmpeg\ffmpeg-20141012-git-20df026 ...
- Tomcat 配置目录
TOMCAT 1.主目录下有bin,conf,lib,logs,temp,webapps,work 1.bin目录主要是用来存放tomcat的命令 2.conf目录主要是用来存放tomcat的一些配置 ...
- [C++]指针与多级指针(图解)
声明:如需引用或者摘抄本博文源码或者其文章的,请在显著处注明,来源于本博文/作者,以示尊重劳动成果,助力开源精神.也欢迎大家一起探讨,交流,以共同进步- 0.0 演示: /* @author:John ...
- Microservice Patterns
https://www.manning.com/books/microservice-patterns http://www.jianshu.com/p/2f32ac949138
- GNU/Linux的GNU是什么意思
这个组织中黑客云集,而且多是掌握核心技术的真正高手,他们的作品多是编译器.词法/语法分析器.底层函数库等大作.更重要的不是他们的技术,而是他们的哲学!他们的哲学就是技术上的“共产主义”——人人为我,我 ...
- argv[1] 路径问题
在看<学习opencv>一书时遇到一个小问题:函数只是通过argv传递参数来读取图片并显示,但是却一直弹出画布,没有图像. 如下:test.c # include<stdio.h&g ...