• 内网入库单管理系统


    案例:入库单管理

    •需求:提供入库单明细的增删改查页面。字段:Id(Guid类型,ItemInserting事件中为主键赋值)、类型(可选值:采购入库、盘盈入库、退货入库,先做成写死的三个项, (*)完成再做一个值来自于另外一张入库单类型表)、入库日期(默认为当天,ItemCreated,TextBox(2008-08-08),(*)使用JQueryUI的datepicker控件)、单价(int)、数量(int) 、金额(int) 。所有字段都不能为空,当用户输入单价或者数量之后自动计算金额(金额=单价*数量),考虑折扣因此金额可以不等于数量*单价,用户还可以修改计算以后的金额。如果数量为负值(红单),则此行显示为红色背景(服务器端、客户端都行)。不允许修改、删除。
     
    aspx页面代码:
    View Code
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="入库单.aspx.cs" Inherits="入库单2.入库单" %>
    
    <!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="CSS/jquery/ui-lightness/jquery-ui-1.8.2.custom.css" rel="stylesheet"
            type="text/css" />
        <script src="JS/jquery-1.4.2.js" type="text/javascript"></script>
        <script src="JS/jquery.ui.datepicker.min.js" type="text/javascript"></script>
        <script src="JS/jquery.ui.core.min.js" type="text/javascript"></script>
        <script src="JS/jquery.ui.widget.min.js" type="text/javascript"></script>
        <script src="JS/jquery.ui.datepicker-zh-CN.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $("input[myid=inDate]").datepicker({ altFormat: 'yy-mm-dd' }).datepicker('option', $.datepicker.regional["zh-CN"]);
    
                var inputblur = function () {
                    if ($("input[myid=price]").val().length > 0 && $("input[myid=count]").val().length > 0) {
                        var result = parseInt($("input[myid=price]").val(), 10) * parseInt($("input[myid=count]").val(), 10);
                        $("input[myid=amount]").val(result);
                    }
                };
    
                $("input[myid=price]").blur(inputblur);
                $("input[myid=count]").blur(inputblur);
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                DeleteMethod="Delete" InsertMethod="Insert" 
                OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                TypeName="入库单2.DAL.DataSetInBillsTableAdapters.T_InBillsTableAdapter" 
                UpdateMethod="Update">
                <InsertParameters>
                    <asp:Parameter DbType="Guid" Name="Id" />
                    <asp:Parameter Name="InType" Type="Int32" />
                    <asp:Parameter Name="InDate" Type="DateTime" />
                    <asp:Parameter Name="Price" Type="Int32" />
                    <asp:Parameter Name="Count" Type="Int32" />
                    <asp:Parameter Name="Amount" Type="Int32" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="InType" Type="Int32" />
                    <asp:Parameter Name="InDate" Type="DateTime" />
                    <asp:Parameter Name="Price" Type="Int32" />
                    <asp:Parameter Name="Count" Type="Int32" />
                    <asp:Parameter Name="Amount" Type="Int32" />
                    <asp:Parameter DbType="Guid" Name="Original_Id" />
                </UpdateParameters>
            </asp:ObjectDataSource>
        
        </div>
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" 
            DataSourceID="ObjectDataSource1" InsertItemPosition="LastItem" 
            oniteminserting="ListView1_ItemInserting" 
            onitemcreated="ListView1_ItemCreated" 
            onitemdatabound="ListView1_ItemDataBound">
    
            <EmptyDataTemplate>
                <table runat="server" style="">
                    <tr>
                        <td>
                            未返回数据。</td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <tr style="">
    
    
                    <td>
                    <asp:DropDownList ID="ddlInType" runat="server" SelectedValue='<%# Bind("InType") %>'>
                    <asp:ListItem Text="采购入库" Value="1"></asp:ListItem>
                    <asp:ListItem Text="盘盈入库" Value="2"></asp:ListItem>
                    <asp:ListItem Text="退货入库" Value="3"></asp:ListItem>
                    </asp:DropDownList>
                    </td>
    
                    <td>
                        <asp:TextBox myid="inDate" ID="InDateTextBox" runat="server" Text='<%# Bind("InDate") %>' />
                    </td>
                    <td>
                        <asp:TextBox myid="price" ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' />
                    </td>
                    <td>
                        <asp:TextBox myid="count" ID="CountTextBox" runat="server" Text='<%# Bind("Count") %>' />
                    </td>
                    <td>
                        <asp:TextBox myid="amount" ID="AmountTextBox" runat="server" Text='<%# Bind("Amount") %>' />
                    </td>
    
                                    <td>
                        <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="插入" />
                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="清除" />
                    </td>
                </tr>
            </InsertItemTemplate>
            <ItemTemplate>
                <tr id="trItem" runat="server">
                    <td>
                    <asp:DropDownList ID="ddlInType" runat="server" SelectedValue='<%# Eval("InType") %>'>
                        <asp:ListItem Text="采购入库" Value="1"></asp:ListItem>
                        <asp:ListItem Text="盘盈入库" Value="2"></asp:ListItem>
                        <asp:ListItem Text="退货入库" Value="3"></asp:ListItem>
                    </asp:DropDownList>
                    </td>
                    <td>
                        <asp:Label ID="InDateLabel" runat="server" Text='<%# Eval("InDate","{0:D}") %>' />
                    </td>
                    <td>
                        <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                    </td>
                    <td>
                        <asp:Label ID="CountLabel" runat="server" Text='<%# Eval("Count") %>' />
                    </td>
                    <td>
                        <asp:Label ID="AmountLabel" runat="server" Text='<%# Eval("Amount") %>' />
                    </td>
                </tr>
            </ItemTemplate>
            <LayoutTemplate>
                <table runat="server">
                    <tr runat="server">
                        <td runat="server">
                            <table ID="itemPlaceholderContainer" runat="server" border="0" style="">
                                <tr runat="server" style="">
                                    <td runat="server">
                                        入库类型</td>
                                    <td runat="server">
                                        入库日期</td>
                                    <td runat="server">
                                        价格</td>
                                    <td runat="server">
                                        数量</td>
                                    <td runat="server">
                                        金额</td>
                                </tr>
                                <tr ID="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr runat="server">
                        <td runat="server" style="">
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
        </asp:ListView>
        </form>
    </body>
    </html>

    aspx.cs页面代码:

    View Code
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Web.UI.HtmlControls;
    
    namespace 入库单2
    {
        public partial class 入库单 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
            {
                e.Values["Id"] = Guid.NewGuid();
                DropDownList ddlInType = (DropDownList)e.Item.FindControl("ddlInType");
                e.Values["InType"] = ddlInType.SelectedValue;
                
            }
    
            protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e)
            {
                if (e.Item.ItemType == ListViewItemType.InsertItem)
                {
                    TextBox InDateTextBox = (TextBox)e.Item.FindControl("InDateTextBox");
                    InDateTextBox.Text = DateTime.Now.ToShortDateString();
                }
            }
    
            protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
            {
                ListViewDataItem lvDataItem = (ListViewDataItem)e.Item;
                DataRowView dataRowView = (DataRowView)lvDataItem.DataItem;
                var billRow = dataRowView.Row as 入库单2.DAL.DataSetInBills.T_InBillsRow;
                if (billRow.Count < 0)
                {
                    HtmlTableRow trItem = (HtmlTableRow)e.Item.FindControl("trItem");
                    trItem.BgColor = "Pink";
                }
            }
    
    
    
        }
    }

    运行界面效果:

     代码附件:入库单2.rar
  • 相关阅读:
    docker 安装ELK
    关于centOS安装配置mysql5.6那点事
    关于centOS安装配置xampp那点事
    PowerDesigner16.5连接Oracle数据库生成E-R图
    Microsoft Visual Studio 中工具箱不显示DevExpress控件的解决办法
    Linux 基础命令
    oracle数据库表空间创建&导入&导出
    weblogic10.3.6漏洞修改方案
    oracle数据库表空间追加数据库文件方法
    转移博客
  • 原文地址:https://www.cnblogs.com/zxx193/p/2985212.html
Copyright © 2020-2023  润新知