您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > 实训七 产品小类管理
实训七产品小类管理实训目的:实训内容:实训过程:1.界面制作(smallClass.aspx页面)该页面全部静态代码如下:%@PageLanguage=C#AutoEventWireup=trueCodeFile=smallClass.aspx.csDebug=trueInherits=bigClass%!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN==servertitle无标题页/titlelinkhref=style.cssrel=stylesheettype=text/css//headbodyformid=form1runat=serverdivasp:ScriptManagerID=ScriptManager1runat=server/asp:ScriptManagertablealign=centercellpadding=0cellspacing=0width=800trtdasp:UpdatePanelID=UpdatePanel1runat=serverContentTemplatetablealign=centercellpadding=0cellspacing=0width=100%style=border:1pxsolid#C0C0C0;margin-top:5px;margin-bottom:5px;trbgcolor=Silvertdalign=centerwidth=200小类名称:/tdtdalign=centerheight=35width=200所属大类:/tdtdalign=centerheight=35width=200小类编号:/tdtdalign=center /td/trtrtdalign=centerasp:TextBoxID=TextBox1runat=serverWidth=92px/asp:TextBox/tdtdalign=centerheight=35asp:DropDownListID=DropDownList1runat=server/asp:DropDownList/tdtdalign=centerheight=35asp:TextBoxID=TextBox2runat=serverWidth=82px/asp:TextBox/tdtdalign=centerasp:ButtonID=Button1runat=serveronclick=Button1_ClickText=添加Width=77px//td/tr/tableasp:GridViewID=GridView1runat=serverAutoGenerateColumns=FalseBackColor=WhiteBorderColor=#3366CCBorderStyle=NoneBorderWidth=1pxCellPadding=4CssClass=gridviewDataKeyNames=idonrowcancelingedit=GridView1_RowCancelingEditonrowdatabound=GridView1_RowDataBoundonrowdeleting=GridView1_RowDeleting1onrowediting=GridView1_RowEditingonrowupdating=GridView1_RowUpdatingWidth=100%FooterStyleBackColor=#99CCCCForeColor=#003399/RowStyleBackColor=WhiteForeColor=#003399/Columnsasp:TemplateFieldHeaderText=大类名称AlternatingItemTemplateasp:LabelID=Label1runat=serverText='%#Bind(bigID)%'/asp:Labelasp:HiddenFieldID=HiddenField2runat=serverValue='%#Eval(bigID)%'//AlternatingItemTemplateEditItemTemplateasp:DropDownListID=DropDownList2runat=server/asp:DropDownListasp:HiddenFieldID=HiddenField1runat=serverValue='%#Eval(bigID)%'//EditItemTemplateItemTemplateasp:LabelID=Label1runat=serverText='%#Bind(bigID)%'/asp:Labelasp:HiddenFieldID=HiddenField2runat=serverValue='%#Eval(bigID)%'//ItemTemplateItemStyleWidth=150px//asp:TemplateFieldasp:BoundFieldDataField=smallNameHeaderText=小类名称ItemStyleWidth=150px//asp:BoundFieldasp:BoundFieldDataField=smallIDHeaderText=小类编号ItemStyleWidth=150px//asp:BoundFieldasp:CommandFieldShowEditButton=True/asp:CommandFieldShowDeleteButton=TrueItemStyleWidth=100px//asp:CommandField/ColumnsPagerStyleBackColor=#99CCCCForeColor=#003399HorizontalAlign=Left/SelectedRowStyleBackColor=#009999Font-Bold=TrueForeColor=#CCFF99/HeaderStyleBackColor=#003399Font-Bold=TrueForeColor=#CCCCFF//asp:GridView/ContentTemplate/asp:UpdatePanel/td/tr/table/div/form/body/html2.动态代码編写(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.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Xml.Linq;publicpartialclassbigClass:System.Web.UI.Page{publicDBfunctiondb=newDBfunction();protectedvoidPage_Load(objectsender,EventArgse){db.isLogin();if(!IsPostBack){binddata();db.initDropDownList(DropDownList1,select*frombigclass,bigName,bigID,null);}}voidbinddata(){GridView1.DataSource=db.getDataView(select*fromsmallClass);GridView1.DataBind();}protectedvoidButton1_Click(objectsender,EventArgse){if(Session[quanxian]!=null&&Session[quanxian].ToString()!=0){ScriptManager.RegisterStartupScript(this,GetType(),,alert('对不起,您的权限不够!'),true);return;}else{if(TextBox1.Text.Trim().Length0&&TextBox2.Text.Trim().Length0){if(!db.isExist(select*fromsmallClasswheresmallID='+TextBox2.Text.Trim()+'andsmallName='+TextBox1.Text.Trim()+'andbigid='+DropDownList1.SelectedValue.ToString()+')){db.sqlExecute(insertintosmallClass(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(),,alert('小类名称和小类编号不能为空'),true);}}}protectedvoidGridView1_RowUpdating(objectsender,GridViewUpdateEventArgse){TextBoxtbsmallName,tbsmallID;DropDownListdrpBigClass;stringsqlcheck=,sqlupdate=;tbsmallID=(TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0];tbsmallName=(TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0];drpBigClass=(DropDownList)GridView1.Rows[e.RowIndex].Cells[0].FindControl(DropDownList2);if(tbsmallName.Text.Trim().Length0&&tbsmallID.Text.Trim().Length0){sqlcheck=select*from(select*fromsmallclasswhereid+GridView1.DataKeys[e.RowIndex].Value+)ast1wheresmallid='+tbsmallID.Text.Trim()+'orsmallname='+tbsmallName.
本文标题:实训七 产品小类管理
链接地址:https://www.777doc.com/doc-487653 .html