產(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頁,還剩5頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、實訓(xùn)七產(chǎn)品小類管理實訓(xùn)目的:實訓(xùn)內(nèi)容: 實訓(xùn)過程:1. 界面制作(smallClass.aspx 頁面)該頁面全部靜態(tài)代碼如下: 無標題頁 TOC o 1-5 h z 小類名稱: 所屬大類: 小類編號: / td / td / td Text = runat =serverrunat =serverrunat =serverText = runat =serverHeaderText =小類名稱小類編號HorizontalAlign =Left /Font-Bold =True ForeColorColumnsasp: HiddenField ID=HiddenField2”Value = /

2、asp: DropDownList ID =DropDownList2asp: HiddenField ID=HiddenField1Value = , /ItemTemplate asp: HiddenField ID=HiddenField2Value = /ItemStyle Width =150px” /asp: BoundField DataField =smallNameasp: BoundField DataField =smallID HeaderText = 2.動態(tài)代碼編寫(smallclass.aspx.cx) using System;using System.Coll

3、ections;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;public partial class bigClass : System

4、.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 , bigNamebigID , null ); void binddata()GridView1.DataSource = db.getDataView(select * from s

5、mallClass );GridView1.DataBind();protected void Button1_Click( object sender, EventArgs e)if (Session quanxian != null & Session quanxian .ToString() !=0 )ScriptManager .RegisterStartupScript( this , GetType(), , alert( 對不起, 您的權(quán)限不夠!) , true );return ;elseif (TextBox1.Text.Trim().Length 0 & TextBox2.

6、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()+ ) db.sqlExecute(insert into smallClass(smallName,smallID,bigID)values( + TextBox1.Text.Trim() +,+ TextBox2.

7、Text.Trim() +,+DropDownList1.SelectedValue.ToString() +) );binddata();elseScriptManager .RegisterStartupScript( this , GetType(), , alert( 小類編號或小類名稱不能相同! ) , true ); else ScriptManager .RegisterStartupScript( this , GetType(), , alert( 小 類名稱和小類編號不能為空) , true );protected void GridView1_RowUpdating( o

8、bject sender, GridViewUpdateEventArgs e)TextBox tbsmallName, tbsmallID;DropDownList drpBigClass;string sqlcheck= ,sqlupdate=tbsmallID = ( TextBox )GridView1.Rowse.RowIndex.Cells2.Controls0;tbsmallName = ( TextBox )GridView1.Rowse.RowIndex.Cells1.Controls0; drpBigClass =( DropDownList )GridView1.Rows

9、e.RowIndex.Cells0.FindControl(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()+ or smallname= +tbsmallName.Text.Trim()+ ;i

10、f (!db.isExist(sqlcheck)db.sqlExecute(update smallClass set smallName= +tbsmallName.Text.Trim() + ,smallID= + tbsmallID.Text.Trim() +,bigID=drpBigClass.SelectedValue.ToString() + where id= +GridView1.DataKeyse.RowIndex.Value);GridView1.EditIndex = -1;binddata(); elseScriptManager .RegisterStartupScr

11、ipt( this , GetType(), , alert( 小 類編號或小類名稱不能相同 ) , true );/GridView1.EditIndex = -1;/ binddata();return ; elseScriptManager .RegisterStartupScript( this , GetType(), , alert( 小類名 稱和小類編號不能為空) , true );protected void GridView1_RowEditing( object sender, GridViewEditEventArgs e)if (Session quanxian !=

12、null & Session quanxian .ToString() !=0 )ScriptManager .RegisterStartupScript( this , GetType(), , alert( 對不起, 您的權(quán)限不夠!) , true );returnelseGridView1.EditIndex = e.NewEditIndex;binddata();protected void GridView1_RowDeleting1( object sender, GridViewDeleteEventArgs e) if (Session quanxian != null & S

13、ession quanxian .ToString() !=0 )ScriptManager .RegisterStartupScript( this , GetType(), , alert( 對不起,您的權(quán)限不夠!) , true );return ;elsedb.sqlExecute(delete from smallClass where id=+GridView1.DataKeyse.RowIndex.Value);binddata();protected void GridView1_RowCancelingEdit( object sender, GridViewCancelEd

14、itEventArgs e)GridView1.EditIndex = -1;binddata();protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e) DataRow dr;Label Lb;DropDownList ddl;HiddenField hf;if (e.Row.RowType = DataControlRowType .DataRow)e.Row.Attributes.Add(onmouseover , bg=this.style.backgroundColor;this.st

15、yle.backgroundColor=#dddddd );e.Row.Attributes.Add(onmouseout , this.style.backgroundColor=bg );DataControlRowState .Alternate | e.Row.RowState =if (e.Row.RowState =DataControlRowState .Normal)Lb = (Label )e.Row.Cells0.FindControl( Label1 );hf = (HiddenField )e.Row.Cells0.FindControl(HiddenField2 );dr = db.getDataRow(select * from bigClass where bigid=hf.Value.ToString() +Lb.Text = dr );bigname .ToString();if (e.Row.RowState = DataControlRowState( DataControlRowState.Alternate | DataControlRow

溫馨提示

  • 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)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論