




版權(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"> 
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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 股權(quán)投資基金投資退出保障擔(dān)保服務(wù)合同
- 商業(yè)地產(chǎn)退租條件及賠償協(xié)議書
- 股權(quán)回購與員工持股計劃相結(jié)合的股權(quán)激勵協(xié)議
- 上市公司股權(quán)擔(dān)保及監(jiān)管協(xié)議
- 股份期權(quán)激勵計劃知識產(chǎn)權(quán)保護合同范本
- 股權(quán)代持及合伙人退伙條件下的轉(zhuǎn)讓協(xié)議
- 股權(quán)代持與員工激勵相結(jié)合的合同范本
- 股權(quán)轉(zhuǎn)讓協(xié)議承諾書(含爭議解決方式)
- 醫(yī)療大數(shù)據(jù)隱私保護技術(shù)在2025年合規(guī)應(yīng)用的法律法規(guī)與標(biāo)準(zhǔn)體系研究報告001
- 工地亮化工程施工方案
- 【小學(xué)】新蘇教版小學(xué)數(shù)學(xué)四年級下冊暑假每日一練(02):計算題-應(yīng)用題(含答案)
- 2025豬藍耳病防控及凈化指南(第三版)
- TCUWA20059-2022城鎮(zhèn)供水管網(wǎng)模型構(gòu)建與應(yīng)用技術(shù)規(guī)程
- 2025至2030中國壓縮空氣儲能產(chǎn)業(yè)現(xiàn)狀調(diào)查及項目投資策略建議報告
- 三臺縣2024-2025學(xué)年小學(xué)六年級數(shù)學(xué)畢業(yè)檢測指導(dǎo)卷含解析
- 宅基地互換合同協(xié)議書范本
- 2025人教版數(shù)學(xué)四年級下冊 第一單元《四則運算》單元分層作業(yè)
- 園藝植物育種學(xué)知到課后答案智慧樹章節(jié)測試答案2025年春浙江大學(xué)
- 集團公司下屬子公司管理制度
- 2025年湖南高速鐵路職業(yè)技術(shù)學(xué)院單招職業(yè)技能考試題庫帶答案
- GB/T 15683-2025糧油檢驗大米直鏈淀粉含量的測定
評論
0/150
提交評論