版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实训七 产品小类管理实训目的:实训内容:实训过程:1. 界面制作页面)该页面全部静态代码如下:<% Page Language="C#" AutoEventWireup="true" CodeFile="smallClass.aspx.cs" Debug="true" Inherits="bigClass" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" ""&g
2、t;<html xmlns=""><head runat="server"> <title>无标题页</title> <link href="style.css" rel="stylesheet" type="text/css" /></head><body> <form id="form1" runat="server"> <div> <as
3、p:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <table align="center" cellpadding="0" cellspacing="0" width="800"> <tr> <td> <asp:UpdatePanel ID="UpdatePanel1" runat="ser
4、ver"> <ContentTemplate> <table align="center" cellpadding="0" cellspacing="0" width="100%" style="border: 1px solid #C0C0C0; margin-top: 5px; margin-bottom: 5px;"> <tr bgcolor="Silver"> <td align="center&qu
5、ot; width="200"> 小类名称:</td> <td align="center" height="35" width="200"> 所属大类:</td> <td align="center" height="35" width="200"> 小类编号:</td> <td align="center"> </td> &
6、lt;/tr> <tr> <td align="center"> <asp:TextBox ID="TextBox1" runat="server" Width="92px"></asp:TextBox> </td> <td align="center" height="35"> <asp:DropDownList ID="DropDownList1" runat=&quo
7、t;server"> </asp:DropDownList> </td> <td align="center" height="35"> <asp:TextBox ID="TextBox2" runat="server" Width="82px"></asp:TextBox> </td> <td align="center"> <asp:Button ID="B
8、utton1" runat="server" onclick="Button1_Click" Text="添加" Width="77px" /> </td> </tr> </table> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderC
9、olor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" CssClass="gridview" DataKeyNames="id" onrowcancelingedit="GridView1_RowCancelingEdit" onrowdatabound="GridView1_RowDataBound" onrowdeleting="GridVi
10、ew1_RowDeleting1" onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating" Width="100%"> <FooterStyle BackColor="#99CCCC" ForeColor="#003399" /> <RowStyle BackColor="White" ForeColor="#003399" /&g
11、t; <Columns> <asp:TemplateField HeaderText="大类名称"> <AlternatingItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("bigID") %>'></asp:Label> <asp:HiddenField ID="HiddenField2" runat="
12、server" Value='<%# Eval("bigID") %>' /> </AlternatingItemTemplate> <EditItemTemplate> <asp:DropDownList ID="DropDownList2" runat="server"> </asp:DropDownList> <asp:HiddenField ID="HiddenField1" runat="serve
13、r" Value='<%# Eval("bigID") %>' /> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("bigID") %>'></asp:Label> <asp:HiddenField ID="HiddenField2" run
14、at="server" Value='<%# Eval("bigID") %>' /> </ItemTemplate> <ItemStyle Width="150px" /> </asp:TemplateField> <asp:BoundField DataField="smallName" HeaderText="小类名称"> <ItemStyle Width="150px" />
15、 </asp:BoundField> <asp:BoundField DataField="smallID" HeaderText="小类编号"> <ItemStyle Width="150px" /> </asp:BoundField> <asp:CommandField ShowEditButton="True" /> <asp:CommandField ShowDeleteButton="True"> <Item
16、Style Width="100px" /> </asp:CommandField> </Columns> <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" /> <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99"
17、 /> <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" /> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> </td> </tr> </table> </div> </form></body></html>2. 动态代码編写(smallclass.
18、aspx.cx)using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;
19、public partial class bigClass : System.Web.UI.Page public DBfunction db = new DBfunction(); protected void Page_Load(object sender, EventArgs e) db.isLogin(); if (!IsPostBack) binddata(); db.initDropDownList(DropDownList1, "select * from bigclass", "bigName", "bigID", n
20、ull); void binddata() GridView1.DataSource = db.getDataView("select * from smallClass"); GridView1.DataBind(); protected void Button1_Click(object sender, EventArgs e) if (Session"quanxian" != null && Session"quanxian".ToString() != "0") ScriptManager.
21、RegisterStartupScript(this, GetType(), "", "alert('对不起,您的权限不够!')", true); return; else if (TextBox1.Text.Trim().Length > 0 && TextBox2.Text.Trim().Length > 0) if (!db.isExist("select * from smallClass where smallID='" + TextBox2.Text.Trim() + &
22、quot;' and smallName='" + TextBox1.Text.Trim() + "' and bigid='" + DropDownList1.SelectedValue.ToString()+"'") db.sqlExecute("insert into smallClass(smallName,smallID,bigID) values('" + TextBox1.Text.Trim() + "','" + TextBo
23、x2.Text.Trim() + "','" + DropDownList1.SelectedValue.ToString() + "')"); binddata(); else ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('小类编号或小类名称不能相同!')", true); else ScriptManager.RegisterStartupScript(this, GetType(), &
24、quot;", "alert('小类名称和小类编号不能为空')", true); protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) TextBox tbsmallName, tbsmallID; DropDownList drpBigClass; string sqlcheck="",sqlupdate="" tbsmallID = (TextBox)GridView1.Rowse.RowIndex.C
25、ells2.Controls0; tbsmallName = (TextBox)GridView1.Rowse.RowIndex.Cells1.Controls0; drpBigClass = (DropDownList)GridView1.Rowse.RowIndex.Cells0.FindControl("DropDownList2"); if (tbsmallName.Text.Trim().Length > 0 && tbsmallID.Text.Trim().Length > 0) sqlcheck="select * fro
26、m (select * from smallclass where id<>" + GridView1.DataKeyse.RowIndex.Value + ") as t1 where smallid='"+ tbsmallID.Text.Trim()+"' or smallname='"+tbsmallName.Text.Trim()+"'" if (!db.isExist(sqlcheck) db.sqlExecute("update smallClass set
27、smallName='" + tbsmallName.Text.Trim() + "',smallID='" + tbsmallID.Text.Trim() + "',bigID='" + drpBigClass.SelectedValue.ToString() + "' where id=" + GridView1.DataKeyse.RowIndex.Value); GridView1.EditIndex = -1; binddata(); else ScriptManag
28、er.RegisterStartupScript(this, GetType(), "", "alert('小类编号或小类名称不能相同')", true); /GridView1.EditIndex = -1; / binddata(); return; else ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('小类名称和小类编号不能为空')", true); protected void GridVi
29、ew1_RowEditing(object sender, GridViewEditEventArgs e) if (Session"quanxian" != null && Session"quanxian".ToString() != "0") ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('对不起,您的权限不够!')", true); return; else GridView
30、1.EditIndex = e.NewEditIndex; binddata(); protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e) if (Session"quanxian" != null && Session"quanxian".ToString() != "0") ScriptManager.RegisterStartupScript(this, GetType(), "", &qu
31、ot;alert('对不起,您的权限不够!')", true); return; else db.sqlExecute("delete from smallClass where id=" + GridView1.DataKeyse.RowIndex.Value); binddata(); protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) GridView1.EditIndex = -1; binddata(); protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) DataRow dr; Label Lb; DropDownList ddl; HiddenField hf; if
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026宁夏吴忠审计局聘请专业人员1名辅助审计工作笔试备考题库及答案详解
- 2025年洛阳市洛龙区工会人员招聘考试试题及答案详解
- 邻水县人力资源和社会保障局2026年公开招募政策性岗位工作人员(121人)笔试参考题库及答案详解
- 婺源县图书馆2026年公开招聘公益性岗位人员笔试模拟试题及答案详解
- 2026福建省晋江自来水股份有限公司招聘若干人笔试备考试题及答案详解
- 2026年广东省汕尾市中小学教师招聘笔试模拟试题及答案详解
- 2026年吉林省白城市工会人员招聘笔试参考试题及答案详解
- 2026舟山普陀华数广电网络有限公司招聘1人笔试备考题库及答案详解
- 2025年内蒙古自治区赤峰市工会人员招聘考试试题及答案详解
- 2026年芜湖市马塘区工会人员招聘考试备考题库及答案详解
- 原发性高血压课件
- 2025至2030年中国笔记本无线网卡行业市场发展现状及投资战略咨询报告
- 肇庆辅警考试题库2025(有答案)
- DB64∕T 2131-2025 建筑施工非常规高处吊篮施工规程
- 厂区生活垃圾管理制度
- 直播公司入股协议书范本
- 励耕计划 申请书
- DB11-T 1771-2020 地源热泵系统运行技术规范
- T-CSAE 186-2021 电动汽车动力蓄电池箱火灾用气体防控装置
- 游戏开发外包合同
- 呼吸机雾化吸入疗法护理实践专家共识
评论
0/150
提交评论