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

下載本文檔

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

文檔簡介

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

2、<htmlxmlns=""><headrunat="server"><title>無標題頁</title><linkhref="style.css"rel="stylesheet"type="text/css"/></head><body><formid="form1"runat="server"><div><asp:ScriptManager

3、ID="ScriptManager1"runat="server"></asp:ScriptManager><tablealign="center"cellpadding="0"cellspacing="0"width="800"><tr><td><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemp

4、late><tablealign="center"cellpadding="0"cellspacing="0"width="100%"style="border:1pxsolid#C0C0C0margin-top:5px;margin-bottom:5px;"><trbgcolor="Silver"><tdalign="center"width="200">小類名稱:</td><

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

6、extBoxID="TextBox1"runat="server"Width="92px"></asp:TextBox></td><tdalign="center"height="35"><asp:DropDownListID="DropDownList1"runat="server"></asp:DropDownList>< /td><tdalign="cent

7、er"height="35"><asp:TextBoxID="TextBox2"runat="server"Width="82px"></asp:TextBox>< /td><tdalign="center"><asp:ButtonID="Button1"runat="server"onclick="Button1_Click"Text="添加"W

8、idth="77px"/>< /td></tr></table><asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"BackColor="White"BorderColor="#3366CC"BorderStyle="None"BorderWidth="1px"CellPadding="4&quo

9、t;CssClass="gridview"DataKeyNames="id"onrowcancelingedit="GridView1_RowCancelingEdit"onrowdatabound="GridView1_RowDataBound"onrowdeleting="GridView1_RowDeleting1"onrowediting="GridView1_RowEditing"onrowupdating="GridView1_RowUpdating&q

10、uot;Width="100%"><FooterStyleBackColor="#99CCCC"ForeColor="#003399"/><RowStyleBackColor="White"ForeColor="#003399"/><Columns>Text =' <%# Bind("bigID") %> runat ="server" runat ="server">

11、 runat ="server"Text =' <%# Bind("bigID") %> runat ="server"HeaderText ="小類名稱">小類編號">HorizontalAlign ="Left" />Font-Bold ="True" ForeColor<asp:TemplateFieldHeaderText="大類名稱"><AlternatingItemTemplat

12、e><asp:LabelID="Label1"runat="server"'></asp:Label><asp:HiddenFieldID="HiddenField2"Value='<%#Eval("bigID")%>./></AlternatingItemTemplate><EditItemTemplate><asp:DropDownListID="DropDownList2"</asp:

13、DropDownList><asp:HiddenFieldID="HiddenField1"Value='<%#Eval("bigID")%>./></EditItemTemplate><ItemTemplate><asp:LabelID="Label1"runat="server"'></asp:Label><asp:HiddenFieldID="HiddenField2"Value='

14、<%#Eval("bigID")%>./></ItemTemplate><ItemStyleWidth="150px"/></asp:TemplateField><asp:BoundFieldDataField="smallName"<ItemStyleWidth="150px"/></asp:BoundField><asp:BoundFieldDataField="smallID"HeaderText=&

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

16、C"ForeColor="#003399”<SelectedRowStyleBackColor="#009999"="#CCFF99"/><HeaderStyleBackColor="#003399"Font-Bold="True"ForeColor="#CCCCFF"/></asp:GridView></ContentTemplate></asp:UpdatePanel></td></tr>

17、</table></div></form></body></html>2.動態(tài)代碼編寫(smallclass.aspx.cx)usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.

18、WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Xml.Linq;publicpartialclassbigClass:System.Web.UI.PagepublicDBfunctiondb=newDBfunction();protectedvoidPage_Load(objectsender,EventArgse)db.isLogin();if(!IsPostBack)binddata();db.initDropDownList(DropDownList1,"select*frombigclass&q

19、uot;,"bigName""bigID",null);voidbinddata()"select * from smallClass");GridView1.DataSource=db.getDataView(GridView1.DataBind();protectedvoidButton1_Click(objectsender,EventArgse)if(Session"quanxian"!=null&&Session"quanxian".ToString()!="

20、0")ScriptManager.RegisterStartupScript(this,GetType(),"","alert('對不起,您的權限不夠!')",true);return;elseif(TextBox1.Text.Trim().Length>0&&TextBox2.Text.Trim().Length>0)if(!db.isExist("select*fromsmallClasswheresmallID='"+TextBox2.Text.Trim()+&quo

21、t;'andsmallName='"+TextBox1.Text.Trim()+"'andbigid='"+DropDownList1.SelectedValue.ToString()+"'")db.sqlExecute("insertintosmallClass(smallName,smallID,bigID)values('"+TextBox1.Text.Trim()+"','"+TextBox2.Text.Trim()+"&#

22、39;,'"+DropDownList1.SelectedValue.ToString()+"')");binddata();elseScriptManager.RegisterStartupScript(this,GetType(),"","alert('小類編號或小類名稱不能相同!')",true);elseScriptManager.RegisterStartupScript(this,GetType(),"","alert('小類名稱和小類編號不能

23、為空')",true);protectedvoidGridView1_RowUpdating(objectsender,GridViewUpdateEventArgse)TextBoxtbsmallName,tbsmallID;DropDownListdrpBigClass;stringsqlcheck="",sqlupdate=""tbsmallID=(TextBox)GridView1.Rowse.RowIndex.Cells2.Controls0;tbsmallName=(TextBox)GridView1.Rowse.RowIn

24、dex.Cells1.Controls0;drpBigClass=(DropDownList)GridView1.Rowse.RowIndex.Cells0.FindControl("DropDownList2");if(tbsmallName.Text.Trim().Length>0&&tbsmallID.Text.Trim().Length>0)sqlcheck="select*from(select*fromsmallclasswhereid<>"+GridView1.DataKeyse.RowIndex.V

25、alue+")ast1wheresmallid='"+tbsmallID.Text.Trim()+"'orsmallname='"+tbsmallName.Text.Trim()+"'"if(!db.isExist(sqlcheck)db.sqlExecute("updatesmallClasssetsmallName='"+tbsmallName.Text.Trim()+"',smallID='"+tbsmallID.Text.Trim(

26、)+"',bigID='"+drpBigClass.SelectedValue.ToString()+"'whereid="+GridView1.DataKeyse.RowIndex.Value);GridView1.EditIndex=-1;binddata();elseScriptManager.RegisterStartupScript(this,GetType(),"","alert('小類編號或小類名稱不能相同')",true);/GridView1.EditInd

27、ex=-1;/binddata();return;elseScriptManager.RegisterStartupScript(this,GetType(),"","alert('小類名稱和小類編號不能為空')",true);protectedvoidGridView1_RowEditing(objectsender,GridViewEditEventArgse)if(Session"quanxian"!=null&&Session"quanxian".ToString()!=&q

28、uot;0")ScriptManager.RegisterStartupScript(this,GetType(),"","alert('對不起,您的權限不夠!')",true);return;elseGridView1.EditIndex=e.NewEditIndex;binddata();protectedvoidGridView1_RowDeleting1(objectsender,GridViewDeleteEventArgse)if(Session"quanxian"!=null&&

29、Session"quanxian".ToString()!="0")ScriptManager.RegisterStartupScript(this,GetType(),"","alert('對不起,您的權限不夠!')",true);return;elsedb.sqlExecute("deletefromsmallClasswhereid="+GridView1.DataKeyse.RowIndex.Value);binddata();protectedvoidGridView1_RowCancelingEdit(objectsender,GridViewCancelEditEventArgse)GridView1.EditIndex=-1;binddata();protectedvoidGridView1_RowDataBound(objectsender,GridViewRowEventArgse)DataRowdr;LabelLb;DropDownL

溫馨提示

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

評論

0/150

提交評論