实训六 产品大类管理

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

实训六产品大类管理实训目的:实训内容:实训过程:1.界面制作(bigClass.aspx页面)该页面全部静态代码如下:%@PageLanguage=C#AutoEventWireup=trueCodeFile=bigClass.aspx.csInherits=bigClass%!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN==servertitle无标题页/title/headbodyformid=form1runat=serverdivasp:ScriptManagerID=ScriptManager1runat=server/asp:ScriptManagertablealign=centercellpadding=0cellspacing=0width=600trtdasp:UpdatePanelID=UpdatePanel1runat=serverContentTemplatetablealign=centercellpadding=0cellspacing=0width=100%style=border:1pxsolid#C0C0C0;margin-top:5px;margin-bottom:5px;trtdalign=rightwidth=100大类名称:/tdtdwidth=120asp:TextBoxID=TextBox1runat=serverWidth=130px/asp:TextBox/tdtdalign=rightheight=35width=100大类编号:/tdtdwidth=120asp:TextBoxID=TextBox2runat=server/asp:TextBox/tdtdalign=centerasp:ButtonID=Button1runat=serveronclick=Button1_ClickText=添加Width=77px//td/tr/tableasp:GridViewID=GridView1runat=serverAutoGenerateColumns=FalseBackColor=WhiteBorderColor=#3366CCBorderStyle=NoneBorderWidth=1pxCellPadding=4Width=100%DataKeyNames=idonrowcancelingedit=GridView1_RowCancelingEditonrowdeleting=GridView1_RowDeleting1onrowediting=GridView1_RowEditingonrowupdating=GridView1_RowUpdatingFooterStyleBackColor=#99CCCCForeColor=#003399/RowStyleBackColor=WhiteForeColor=#003399/Columnsasp:BoundFieldDataField=bigIDHeaderText=大类编号/asp:BoundFieldDataField=bigNameHeaderText=大类名称ItemStyleWidth=200px//asp:BoundFieldasp:CommandFieldShowEditButton=True/asp:CommandFieldShowDeleteButton=True//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.动态代码编写(bigClass.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{DBfunctiondb=newDBfunction();protectedvoidPage_Load(objectsender,EventArgse){db.isLogin();if(!IsPostBack){binddata();}}voidbinddata(){GridView1.DataSource=db.getDataView(select*frombigClass);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*frombigClasswherebigID='+TextBox2.Text.Trim()+'orbigName='+TextBox1.Text.Trim()+')){db.sqlExecute(insertintobigClass(bigName,bigID)values('+TextBox1.Text.Trim()+','+TextBox2.Text.Trim()+'));binddata();}else{ScriptManager.RegisterStartupScript(this,GetType(),,alert('大类编号或大类名称不能相同!'),true);}}else{ScriptManager.RegisterStartupScript(this,GetType(),,alert('大类名称和大类编号不能为空'),true);}}}protectedvoidGridView1_RowUpdating(objectsender,GridViewUpdateEventArgse){TextBoxtbName,tbID;stringsqlcheck=;tbID=(TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0];tbName=(TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0];if(tbName.Text.Trim().Length0&&tbID.Text.Trim().Length0){sqlcheck=select*from(select*frombigllclasswhereid+GridView1.DataKeys[e.RowIndex].Value+)ast1wherebigid='+tbID.Text.Trim()+'orbigname='+tbName.Text.Trim()+';if(!db.isExist(sqlcheck)){db.sqlExecute(updatebigClasssetbigName='+tbName.Text.Trim()+',bigID='+tbID.Text.Trim()+'whereid=+GridView1.DataKeys[e.RowIndex].Value);GridView1.EditIndex=-1;binddata();}else{ScriptManager.RegisterStartupScript(this,GetType(),,alert('大类编号或大类名称不能相同'),true);//GridView1.EditIndex=-1;//binddata();return;}}else{ScriptManager.RegisterStartupScript(this,GetType(),,alert('大类名称和大类编号不能为空'),true);}}protectedvoidGridView1_RowEditing(objectsender,GridViewEditEventArgse){GridView1.EditIndex=e.NewEditIndex;binddata();}protectedvoidGridView1_RowDeleting1(objectsender,GridViewDeleteEventArgse){if(Session[quanxian]!=null&&Session[quanxian].ToString()!=0){ScriptManager.RegisterStartupScript(this,GetType(),,alert('对不起,您的权限不够!'),true);return;}else{db.sqlExecute(deletefrombigClasswhereid=+GridView1.DataKeys[e.RowIndex].Value);binddata();}}protectedvoidGridView1_RowCancelingEdit(objectsender,GridViewCancelEditEventArgse){GridView1.EditIndex=-1;binddata();}}

1 / 6
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功