產(chǎn)品小類管理實訓(xùn)_第1頁
產(chǎn)品小類管理實訓(xùn)_第2頁
產(chǎn)品小類管理實訓(xùn)_第3頁
產(chǎn)品小類管理實訓(xùn)_第4頁
產(chǎn)品小類管理實訓(xùn)_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、 實訓(xùn)七 產(chǎn)品小類管理實訓(xùn)目的:實訓(xùn)容:實訓(xùn)過程:1. 界面制作(smallClass.aspx頁面)該頁面全部靜態(tài)代碼如下:<%PageLanguage="C#"AutoEventWireup="true"CodeFile="smallClass.aspx.cs"Debug="true"Inherits="bigClass"%><!DOCTYPEhtmlPUBLIC"-/W3C/DTD XHTML 1.0 Transitional/EN"".w3

2、.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="./1999/xhtml"><headrunat="server"><title>無標(biāo)題頁</title><linkhref="style.css"rel="stylesheet"type="text/css"/></head><body><formid="f

3、orm1"runat="server"><div><asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><tablealign="center"cellpadding="0"cellspacing="0"width="800"><tr><td><asp:UpdatePanel

4、ID="UpdatePanel1"runat="server"><ContentTemplate><tablealign="center"cellpadding="0"cellspacing="0"width="100%"style="border: 1pxsolid#C0C0C0; margin-top: 5px; margin-bottom: 5px;"><trbgcolor="Silver"&g

5、t;<tdalign="center"width="200">小類名稱:</td><tdalign="center"height="35"width="200">所屬大類:</td><tdalign="center"height="35"width="200">小類編號:</td><tdalign="center">&nbsp

6、;</td></tr><tr><tdalign="center"><asp:TextBoxID="TextBox1"runat="server"Width="92px"></asp:TextBox></td><tdalign="center"height="35"><asp:DropDownListID="DropDownList1"runat="

7、;server"></asp:DropDownList></td><tdalign="center"height="35"><asp:TextBoxID="TextBox2"runat="server"Width="82px"></asp:TextBox></td><tdalign="center"><asp:ButtonID="Button1"run

8、at="server"onclick="Button1_Click"Text="添加"Width="77px"/></td></tr></table><asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"BackColor="White"BorderColor="#3366CC"Borde

9、rStyle="None"BorderWidth="1px"CellPadding="4"CssClass="gridview"DataKeyNames="id"onrowcancelingedit="GridView1_RowCancelingEdit"onrowdatabound="GridView1_RowDataBound"onrowdeleting="GridView1_RowDeleting1"onrowediting=&q

10、uot;GridView1_RowEditing"onrowupdating="GridView1_RowUpdating"Width="100%"><FooterStyleBackColor="#99CCCC"ForeColor="#003399"/><RowStyleBackColor="White"ForeColor="#003399"/><Columns><asp:TemplateFieldHeaderText

11、="大類名稱"><AlternatingItemTemplate><asp:LabelID="Label1"runat="server"Text='<%# Bind("bigID") %>'></asp:Label><asp:HiddenFieldID="HiddenField2"runat="server"Value='<%# Eval("bigID") %>

12、'/></AlternatingItemTemplate><EditItemTemplate><asp:DropDownListID="DropDownList2"runat="server"></asp:DropDownList><asp:HiddenFieldID="HiddenField1"runat="server"Value='<%# Eval("bigID") %>'/></E

13、ditItemTemplate><ItemTemplate><asp:LabelID="Label1"runat="server"Text='<%# Bind("bigID") %>'></asp:Label><asp:HiddenFieldID="HiddenField2"runat="server"Value='<%# Eval("bigID") %>'/><

14、;/ItemTemplate><ItemStyleWidth="150px"/></asp:TemplateField><asp:BoundFieldDataField="smallName"HeaderText="小類名稱"><ItemStyleWidth="150px"/></asp:BoundField><asp:BoundFieldDataField="smallID"HeaderText="小類編號&qu

15、ot;><ItemStyleWidth="150px"/></asp:BoundField><asp:CommandFieldShowEditButton="True"/><asp:CommandFieldShowDeleteButton="True"><ItemStyleWidth="100px"/></asp:CommandField></Columns><PagerStyleBackColor="#99C

16、CCC"ForeColor="#003399"HorizontalAlign="Left"/><SelectedRowStyleBackColor="#009999"Font-Bold="True"ForeColor="#CCFF99"/><HeaderStyleBackColor="#003399"Font-Bold="True"ForeColor="#CCCCFF"/></asp:Gri

17、dView></ContentTemplate></asp:UpdatePanel></td></tr></table></div></form></body></html>2. 動態(tài)代碼編寫(smallclass.aspx.cx)using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using Sys

18、tem.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;publicpartialclassbigClass : System.Web.UI.PagepublicDBfunction db = newDBfunction();protectedvoid Page_Load(object sender, EventArgs e

19、) db.isLogin();if (!IsPostBack) binddata(); db.initDropDownList(DropDownList1, "select * from bigclass", "bigName", "bigID", null); void binddata() GridView1.DataSource = db.getDataView("select * from smallClass"); GridView1.DataBind(); protectedvoid Button1_C

20、lick(object sender, EventArgs e) if (Session"quanxian" != null && Session"quanxian".ToString() != "0") ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('對不起,您的權(quán)限不夠!')", true);return; else if (TextBox1.Text.Trim().Length

21、 > 0 && TextBox2.Text.Trim().Length > 0) if (!db.isExist("select * from smallClass where smallID='" + TextBox2.Text.Trim() + "' and smallName='" + TextBox1.Text.Trim() + "' and bigid='" + DropDownList1.SelectedValue.ToString()+"

22、9;") db.sqlExecute("insert into smallClass(smallName,smallID,bigID) values('" + TextBox1.Text.Trim() + "','" + TextBox2.Text.Trim() + "','" + DropDownList1.SelectedValue.ToString() + "')"); binddata(); else ScriptManager.RegisterSt

23、artupScript(this, GetType(), "", "alert('小類編號或小類名稱不能一樣!')", true); else ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('小類名稱和小類編號不能為空')", true); protectedvoid GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) Text

24、Box tbsmallName, tbsmallID;DropDownList drpBigClass;string sqlcheck="",sqlupdate="" tbsmallID = (TextBox)GridView1.Rowse.RowIndex.Cells2.Controls0; tbsmallName = (TextBox)GridView1.Rowse.RowIndex.Cells1.Controls0; drpBigClass = (DropDownList)GridView1.Rowse.RowIndex.Cells0.FindCo

25、ntrol("DropDownList2");if (tbsmallName.Text.Trim().Length > 0 && tbsmallID.Text.Trim().Length > 0) sqlcheck="select * from (select * from smallclass where id<>" + GridView1.DataKeyse.RowIndex.Value + ") as t1 where smallid='"+ tbsmallID.Text.Trim

26、()+"' or smallname='"+tbsmallName.Text.Trim()+"'"if (!db.isExist(sqlcheck) db.sqlExecute("update smallClass set smallName='" + tbsmallName.Text.Trim() + "',smallID='" + tbsmallID.Text.Trim() + "',bigID='" + drpBigClass

27、.SelectedValue.ToString() + "' where id=" + GridView1.DataKeyse.RowIndex.Value); GridView1.EditIndex = -1; binddata(); else ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('小類編號或小類名稱不能一樣')", true);/GridView1.EditIndex = -1;/ binddata();return

28、; else ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('小類名稱和小類編號不能為空')", true); protectedvoid GridView1_RowEditing(object sender, GridViewEditEventArgs e) if (Session"quanxian" != null && Session"quanxian".ToString() != "0

29、") ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('對不起,您的權(quán)限不夠!')", true);return; else GridView1.EditIndex = e.NewEditIndex; binddata(); protectedvoid GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e) if (Session"quanxian" !=

30、null && Session"quanxian".ToString() != "0") ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('對不起,您的權(quán)限不夠!')", true);return; else db.sqlExecute("delete from smallClass where id=" + GridView1.DataKeyse.RowIndex.Value); binddata(); protectedvoid GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) GridView1.EditIndex = -1; binddata(); protectedvoid GridView1_RowDataBound(object sender, GridViewRowEventArgs e) DataRow dr;Label Lb;DropDownList ddl;HiddenField hf;if (e.Row.RowType = Dat

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論