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

下載本文檔

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

文檔簡介

1、實訓七 產品小類治理實訓目的:實訓內容:實訓過程:界面制作(smallClass.aspx頁面)該頁面全部靜態(tài)代碼如下: 無標題頁 小類名稱: 所屬大類: 小類編號: asp:Label ID=Label1 runat=server Text= asp:HiddenField ID=HiddenField2 runat=server Value= / asp:HiddenField ID=HiddenField1 runat=server Value= / asp:Label ID=Label1 runat=server Text= asp:HiddenField ID=HiddenField

2、2 runat=server Value= / 動態(tài)代碼編寫(smallclass.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.W

3、ebControls.WebParts;using System.Xml.Linq;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, bi

4、gID, null); void binddata() GridView1.DataSource = db.getDataView(select * from smallClass); GridView1.DataBind(); protected void Button1_Click(object sender, EventArgs e) if (Sessionquanxian != null & Sessionquanxian.ToString() != 0) ScriptManager.RegisterStartupScript(this, GetType(), , alert(對不起,

5、您的權限不夠!), 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() + and smallName= + TextBox1.Text.Trim() + and bigid= + DropDownList1.SelectedValue.ToString()+) db.sqlExecute(insert into sm

6、allClass(smallName,smallID,bigID) values( + TextBox1.Text.Trim() + , + TextBox2.Text.Trim() + , + DropDownList1.SelectedValue.ToString() + ); binddata(); else ScriptManager.RegisterStartupScript(this, GetType(), , alert(小類編號或小類名稱不能相同!), true); else ScriptManager.RegisterStartupScript(this, GetType()

7、, , alert(小類名稱和小類編號不能為空), true); protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) TextBox tbsmallName, tbsmallID; DropDownList drpBigClass; string sqlcheck=,sqlupdate=; tbsmallID = (TextBox)GridView1.Rowse.RowIndex.Cells2.Controls0; tbsmallName = (TextBox)GridView1.Rows

8、e.RowIndex.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 * from smallclass where id + GridView1.DataKeyse.RowIndex.Value + ) as t1 where s

9、mallid=+ tbsmallID.Text.Trim()+ or smallname=+tbsmallName.Text.Trim()+; if (!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.V

10、alue); GridView1.EditIndex = -1; binddata(); else ScriptManager.RegisterStartupScript(this, GetType(), , alert(小類編號或小類名稱不能相同), true); /GridView1.EditIndex = -1; / binddata(); return; else ScriptManager.RegisterStartupScript(this, GetType(), , alert(小類名稱和小類編號不能為空), true); protected void GridView1_Row

11、Editing(object sender, GridViewEditEventArgs e) if (Sessionquanxian != null & Sessionquanxian.ToString() != 0) ScriptManager.RegisterStartupScript(this, GetType(), , alert(對不起,您的權限不夠!), true); return; else GridView1.EditIndex = e.NewEditIndex; binddata(); protected void GridView1_RowDeleting1(object

12、 sender, GridViewDeleteEventArgs e) if (Sessionquanxian != null & Sessionquanxian.ToString() != 0) ScriptManager.RegisterStartupScript(this, GetType(), , alert(對不起,您的權限不夠!), true); return; else db.sqlExecute(delete from smallClass where id= + GridView1.DataKeyse.RowIndex.Value); binddata(); protecte

13、d 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 (e.Row.RowType = DataControlRowType.DataRow) e

14、.Row.Attributes.Add(onmouseover, bg=this.style.backgroundColor; this.style.backgroundColor=#dddddd); e.Row.Attributes.Add(onmouseout, this.style.backgroundColor=bg); if (e.Row.RowState = DataControlRowState.Alternate | 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 = drbigname.ToString(); if (e.Row.RowState = DataControlRowState.Edit | e.Row.RowState = (DataControlRowState.Alternate

溫馨提示

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

評論

0/150

提交評論