版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实训七产品小类管理实训目的:实训内容: 实训过程:1. 界面制作(smallClass.aspx 页面)该页面全部静态代码如下: 无标题页 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.动态代码编写(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( 对不起, 您的权限不够!) , 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( 对不起, 您的权限不够!) , 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( 对不起,您的权限不够!) , 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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026公务员时事政治热点题库(含答案)
- 2026成都市香城中学高一语文分班考试真题含答案
- 鼠疫疫情公众心理疏导与谣言应对课件
- 寨卡病毒孕妇防护与出生缺陷警示课件
- 2026年企业文化激励员工激励试题及答案
- 2026年数字货币与金融科技工程师试题及答案
- 2026年药剂学基础知识试题库(含答案)
- 2026年室内质控操作三基三严培训计划
- 2026年羊水栓塞识别与团队抢救三基培训考核计划
- 2026年往来账款清理管控练习题及答案
- 【《镁空气电池的研究现状文献综述》2400字】
- 教育研究方法(第2版)课件 邵光华 导言及第1-4章 教育研究基本理论 -教育调查研究
- CT防护教学课件
- 2025年天津市公职人员时事政治考试试题(附含答案)
- 登杆作业安全知识培训课件
- 2025北京定向选调生笔试题(含解析)
- FQc部门管理制度
- 《论文写作技巧》课件
- 2024环保无人机监测及数据处理合同
- 《动画素描(第2版)》中职全套教学课件
- 资产评估公司后续教育制度
评论
0/150
提交评论