ERP商品类型管理相关业务处理(三十二)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 
     [email protected])
	
	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商品类型管理相关业务处理(三十二)的主要内容,如果未能解决你的问题,请参考以下文章

ERP商品管理系统哪个比较好

旺店通erp系统怎么弄直接生产

ERP合同管理(二十六)

BetaFlight模块设计之三十二:MSP协议模块分析

有哪些erp系统软件?

深度学习核心技术精讲100篇(三十二)-网易实时数仓实战应用