这是aspx的
<body>
<form id="Form1" style="TABLE-LAYOUT: fixed" method="post" runat="server">
<asp:panel id="Panel1" runat="server" HorizontalAlign="Center" Height="16px">
<asp:Label id="Label2" runat="server" Font-Size="X-Large" Font-Bold="True">用户进货</asp:Label>
</asp:panel><asp:panel id="Panel2" runat="server" HorizontalAlign="Center" Width="785px">
<P></P>
<FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体">
</FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT><FONT face="宋体"></FONT>
<TABLE id="Table3" style="WIDTH: 781px; HEIGHT: 192px" cellSpacing="1" cellPadding="1"
width="781" border="1">
<TR>
<TD style="WIDTH: 173px" align="center">品名</TD>
<TD style="WIDTH: 152px">
<asp:DropDownList id="DropDownList2" runat="server" Width="174px"></asp:DropDownList></TD>
<TD style="WIDTH: 63px" align="center">数量</TD>
<TD>
<asp:TextBox id="TextBox2" runat="server" Width="46px"></asp:TextBox></TD>
<TD style="WIDTH: 110px" align="center">单价(元)</TD>
<TD style="WIDTH: 62px"><FONT face="宋体">
<asp:Label id="Label3" runat="server" Font-Size="X-Small" Width="83px">Label</asp:Label></FONT></TD>
<TD style="WIDTH: 52px" align="center">单位</TD>
<TD>
<asp:DropDownList id="DropDownList3" runat="server" Width="74px"></asp:DropDownList></TD>
<TD>
<asp:Button id="Button1" runat="server" Width="58px" Text="添加"></asp:Button></TD>
</TR>
<TR>
<TD vAlign="top" colSpan="9">
<TABLE id="Table1" style="TABLE-LAYOUT: fixed; WIDTH: 772px; HEIGHT: 150px" cellSpacing="1"
cellPadding="1" width="772" align="center" border="1" runat="server">
<TR>
<TD style="WIDTH: 175px" align="center"><FONT face="宋体">产品名称</FONT></TD>
<TD style="WIDTH: 87px" align="center"><FONT face="宋体">数量</FONT></TD>
<TD style="WIDTH: 129px" align="center"><FONT face="宋体">单价(元)</FONT></TD>
<TD style="WIDTH: 125px" align="center"><FONT face="宋体">单位</FONT></TD>
<TD style="WIDTH: 159px" align="center"><FONT face="宋体">总价(元)</FONT></TD>
<TD align="center"><FONT face="宋体">删除</FONT></TD>
</TR>
<TR>
<TD vAlign="top" colSpan="6"><FONT face="宋体">
<TABLE id="Table2" style="TABLE-LAYOUT: fixed; WIDTH: 766px; HEIGHT: 99px" cellSpacing="1"
cellPadding="1" width="766" border="0">
<TR>
<TD style="WIDTH: 121px">合计</TD>
<TD colSpan="6">
<asp:Label id="Label1" runat="server" Width="456px">Label</asp:Label></TD>
</TR>
<TR>
<TD style="WIDTH: 121px">备注</TD>
<TD colSpan="6">
<asp:TextBox id="TextBox1" runat="server" Width="640px"></asp:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 121px">运输方式:</TD>
<TD colSpan="6">
<asp:DropDownList id="DropDownList1" runat="server" Width="160px"></asp:DropDownList></TD>
</TR>
<TR>
<TD style="WIDTH: 121px">收货地址:</TD>
<TD style="WIDTH: 273px">
<asp:TextBox id="TextBox3" runat="server" Width="252px"></asp:TextBox></TD>
<TD style="WIDTH: 141px">收货人:</TD>
<TD style="WIDTH: 67px">
<asp:TextBox id="TextBox4" runat="server" Width="71px"></asp:TextBox></TD>
<TD style="WIDTH: 67px">电话:</TD>
<TD colSpan="2">
<asp:TextBox id="TextBox5" runat="server"></asp:TextBox></TD>
</TR>
</TABLE>
</FONT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<asp:Button id="Button3" runat="server" Width="65px" Text="提 交"></asp:Button>
<FONT face="宋体"> </FONT>
<asp:Button id="Button4" runat="server" Width="59px" Text="重 置"></asp:Button>
下面是代码:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace lkjxc
{
/// <summary>
/// custommain 的摘要说明。
/// </summary>
public class custommain : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox5;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.DropDownList DropDownList3;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Panel Panel2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Panel Panel3;
protected System.Web.UI.WebControls.DropDownList DropDownList4;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.DropDownList DropDownList5;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Panel Panel4;
protected System.Web.UI.WebControls.TextBox TextBox6;
protected System.Web.UI.WebControls.TextBox TextBox7;
protected System.Web.UI.WebControls.TextBox TextBox8;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.HtmlControls.HtmlTable Table1;
protected System.Web.UI.WebControls.Button Button4;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
ArrayList arryse=new ArrayList();
ArrayList arryse1=(ArrayList)Session["ar"];
if(Page.IsPostBack==true)
{
if(Session["id"].ToString()=="1" && Session["ar"]!=null)
{
ArrayList hwqdbefor=(ArrayList)Session["ar"];
Session["id"]="2";
for(int j=0;j<arryse1.Count/4;j++)
{
HtmlTableRow row=new HtmlTableRow();
for(int i=0;i<4;i++)
{
HtmlTableCell cell=new HtmlTableCell();
cell.Style.Add("font-size","xx-small");
cell.Align="center";
cell.InnerText="华文新魏"+j.ToString();
row.Cells.Add(cell);
}
HtmlTableCell cell1=new HtmlTableCell();
cell1.InnerText="15";
row.Cells.Add(cell1);
HtmlTableCell cell2=new HtmlTableCell();
LinkButton delbutton=new LinkButton();
delbutton.Text="删除";
delbutton.CommandName=j.ToString ();
//Response.Write("<script>alert('"+j.ToString()+"');</script>");
delbutton.Command+=new CommandEventHandler(delbutton_Command);
cell2.Controls.Add(delbutton);
row.Cells.Add(cell2);
this.Table1.Rows.Insert(this.Table1.Rows.Count-1,row);
}
}
}
switch(Request["custom"].ToString())
{
case "用户进货":
this.Label2.Text="用户进货";
this.Panel2.Visible=true;
this.Panel3.Visible=false;
this.Panel4.Visible=false;
break;
case "进货历史":
this.Label2.Text="进货历史";
this.Panel3.Visible=true;
this.Panel2.Visible=false;
this.Panel4.Visible=false;
break;
case "密码维护":
this.Label2.Text="密码维护";
this.Panel4.Visible=true;
this.Panel3.Visible=false;
this.Panel2.Visible=false;
break;
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
ArrayList arryse=new ArrayList();
if(Session["ar"]!=null)
{
ArrayList hwqdbefor=(ArrayList)Session["ar"];
if(Session["id"].ToString()=="2")
{
for(int p=1;p<=hwqdbefor.Count/4;p++)
{
this.Table1.Rows.RemoveAt(1);
}
}
string[] hwqd=new string[hwqdbefor.Count+4];
hwqd[0]=this.DropDownList2.SelectedValue.ToString();
hwqd[1]=this.TextBox2.Text;
hwqd[2]=this.Label3.Text;
hwqd[3]=this.DropDownList3.SelectedValue.ToString();
for(int k=4;k<hwqdbefor.Count;k++)
{
hwqd[k]=hwqdbefor[k-4].ToString();
}
for(int i=0;i<hwqd.Length;i++)
{
arryse.Add(hwqd[i]);
}
}
else
{
string[] hwqd=new string[4];
hwqd[0]=this.DropDownList2.SelectedValue.ToString();
hwqd[1]=this.TextBox2.Text;
hwqd[2]=this.Label3.Text;
hwqd[3]=this.DropDownList3.SelectedValue.ToString();
for(int i=0;i<4;i++)
{
arryse.Add(hwqd[i]);
}
}
Session.Add("ar",arryse);
ArrayList arryse1=(ArrayList)Session["ar"];
Session.Add("id","1");
for(int j=0;j<arryse1.Count/4;j++)
{
HtmlTableRow row=new HtmlTableRow();
for(int i=0;i<4;i++)
{
HtmlTableCell cell=new HtmlTableCell();
cell.Style.Add("font-size","xx-small");
cell.Align="center";
cell.InnerText=j.ToString();
row.Cells.Add(cell);
}
HtmlTableCell cell1=new HtmlTableCell();
cell1.InnerText="15";
row.Cells.Add(cell1);
HtmlTableCell cell2=new HtmlTableCell();
LinkButton delbutton=new LinkButton();
delbutton.Text="删除";
cell2.Controls.Add(delbutton);
row.Cells.Add(cell2);
this.Table1.Rows.Insert(this.Table1.Rows.Count-1,row);
}
}
private void delbutton_Command(object sender, CommandEventArgs e)
{
ArrayList arryse=new ArrayList();
arryse=(ArrayList)Session["ar"];
Response.Write("<script>alert('"+Session["id"].ToString()+"');</script>");
if(arryse.Count>4)
{
for(int p=1;p<=arryse.Count/4;p++)
{
this.Table1.Rows.RemoveAt(1);
}
arryse.RemoveRange(Convert.ToInt32(e.CommandName)*4,4);
Session["ar"]=arryse;
for(int j=0;j<arryse.Count/4;j++)
{
HtmlTableRow row=new HtmlTableRow();
for(int i=0;i<4;i++)
{
HtmlTableCell cell=new HtmlTableCell();
cell.Style.Add("font-size","xx-small");
cell.InnerText=arryse[4*j+i].ToString();
cell.Align="center";
row.Cells.Add(cell);
}
HtmlTableCell cell1=new HtmlTableCell();
cell1.InnerText="15";
row.Cells.Add(cell1);
HtmlTableCell cell2=new HtmlTableCell();
LinkButton delbutton=new LinkButton();
delbutton.Text="删除";
cell2.Controls.Add(delbutton);
row.Cells.Add(cell2);
this.Table1.Rows.Insert(this.Table1.Rows.Count-1,row);
}
Session["id"]="1";
}
else
{
Session["id"]="0";
this.Table1.Rows.RemoveAt(1);
arryse.RemoveRange(0,4);
Response.Write("<script>alert('"+Session["id"].ToString()+"');</script>");
}
}
}
}
以上就是全部内容