ASP.NET餐饮管理系统制作代码分享
程序员文章站
2023-12-19 23:19:28
页面介绍展示:
以上是餐饮管理系统制作图片介绍,接下来是代码部分。
menu.aspx
<%@ page lang...
页面介绍展示:
以上是餐饮管理系统制作图片介绍,接下来是代码部分。
menu.aspx
<%@ page language="c#" masterpagefile="~/masterpage.master" autoeventwireup="true" codefile="menu.aspx.cs" inherits="menu" title="无标题页" %> <asp:content id="content1" contentplaceholderid="contentplaceholder1" runat="server"> <form id="form1" runat="server"> < style="height: 300px"> <asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" datasourceid="sqldatasource1" height="299px" width="544px" allowpaging="true" pagesize="4"> <pagersettings firstpagetext="首页" lastpagetext="末页" mode="nextpreviousfirstlast" nextpagetext="下一页" previouspagetext="上一页" /> <columns> <asp:boundfield datafield="menuid" headertext="序号" insertvisible="false" readonly="true" sortexpression="menuid" /> <asp:boundfield datafield="menuname" headertext="菜名" sortexpression="menuname" /> <asp:imagefield dataimageurlfield="menuphoto" headertext="图片" controlstyle-height="30px" controlstyle-width="70px" sortexpression="menuphoto" > <controlstyle height="30px" width="70px"></controlstyle> </asp:imagefield> <asp:boundfield datafield="menucooker" headertext="厨师" sortexpression="menucooker" /> <asp:boundfield datafield="menustyle" headertext="菜系" sortexpression="menustyle" /> <asp:boundfield datafield="menuprice" headertext="价格" sortexpression="menuprice" /> <asp:boundfield datafield="menudate" headertext="创菜日期" sortexpression="menudate" /> </columns> </asp:gridview> <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:connstr %>" selectcommand="select [menuid], [menuname], [menuphoto], [menucooker], [menustyle], [menuprice], [menudate] from [menus]"> </asp:sqldatasource> </> </form> </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder2" runat="server"> < style=" height:300px "> <asp:datalist id="datalist1" runat="server" datasourceid="sqldatasource2"> <headertemplate > <table border="1" style="width: 104%; height: 36px"> <tr> <td>图片</td> <td>菜名</td> <td>原价格</td> <td>优惠价格</td> </tr> </headertemplate> <itemtemplate> <tr> <td style="width: 90px"> <asp:image id="image1" runat="server" height="88px" imageurl='<%# eval("menuphoto") %>' width="88px" /> </td> <td style="width: 40px"> <asp:label id="label1" runat="server" text='<%# eval("menuname") %>'></asp:label> </td> <td style="width: 50px"> <asp:label id="label2" runat="server" text='<%# eval("menuprice") %>'></asp:label> </td> <td style="width: 50px"> <asp:label id="label3" runat="server" text='<%# eval("menunewprice") %>'></asp:label> </td> </tr> </itemtemplate> <footertemplate></table></footertemplate> </asp:datalist> <asp:sqldatasource id="sqldatasource2" runat="server" connectionstring="<%$ connectionstrings:connstr %>" selectcommand="select [menuname], [menuphoto], [menunewprice], [menuprice] from [menus] where ([menunewprice] is not null)"> </asp:sqldatasource> </> </asp:content>
menucar.aspx
<%@ page language="c#" masterpagefile="~/land-zhuce.master" autoeventwireup="true" codefile="menucar.aspx.cs" inherits="menucar" title="无标题页" %> <asp:content id="content1" contentplaceholderid="contentplaceholder1" runat="server"> <form id="form1" runat="server"> < style="height:350px"> <table id="table1" cellspacing="1" cellpadding="0" width="530" align="center" border="0"> <tr> <td align="center"> <asp:label id="label1" runat="server" font-size="x-large" font-names="华文行楷" forecolor="blue">订餐车</asp:label></td> </tr> <tr> <td align="center"> <asp:datalist id="datalist1" runat="server" bordercolor="tan" borderwidth="1px" cellpadding="2" forecolor="black" datakeyfield="id" onupdatecommand="datalist1_updatecommand" ondeletecommand="datalist1_deletecommand" allowpaging="true" pagesize="4" repeatcolumns="4"> <%-- <alternatingitemstyle backcolor="palegoldenrod" /> <selecteditemstyle backcolor="darkslateblue" forecolor="ghostwhite" />--%> <headertemplate> <table border="1" style="width: 100%"> <tr> <td style="width: 25px"> 序号</td> <td style="width: 33px"> 菜名</td> <td style="width: 49px"> 图片</td> <td style="width: 30px"> 付费</td> <td> 份数</td> <td> 保存份数</td> <td> 删除</td> </tr> </headertemplate> <headerstyle backcolor="tan" font-bold="true" /> <itemtemplate> <tr> <td><%# databinder.eval(container.dataitem ,"goodid") %></td> <td><%# databinder.eval(container.dataitem ,"menuname") %></td> <%-- <td><%# databinder.eval(container.dataitem ,"menuphoto") %></td>--%> <td><asp:image id="image1" runat="server" width="60px" height="40px" imageurl='<%# databinder.eval(container.dataitem ,"menuphurl") %>'></asp:image></td> <td><%# databinder.eval(container.dataitem ,"paymoney") %></td> <td><asp:textbox id="txtcount" runat="server" width="32px" text='<%# databinder.eval(container.dataitem ,"number") %>'></asp:textbox></td> <td><asp:button id="bnmod" runat="server" text="保存修改" commandname="update"></asp:button></td> <td><asp:button id="button1" runat="server" text="删除" commandname= "delete"/></td> </tr> </itemtemplate> <footertemplate></table></footertemplate> <footerstyle backcolor="tan" /> </asp:datalist> </td> </tr> <tr> <td align="center" height="40">总金额: <asp:textbox id="total_money_txt" runat="server" width="82px"></asp:textbox> <asp:button id="shoppingbtn" runat="server" text="继续购物" onclick="shoppingbtn_click"></asp:button> <asp:button id="delallbtn" runat="server" text="清空购物车" onclick="delallbtn_click"></asp:button> <asp:button id="orderbtn" runat="server" text="结算中心" onclick="orderbtn_click"></asp:button></td> </tr> <tr> <td align="center"></td> </tr> <tr> <td align="center"> </td> </tr> </table> </> </form> </asp:content>
menucar.aspx.cs
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.webcontrols.webparts; using system.xml.linq; public partial class menucar : system.web.ui.page { string sqlstr; db db = new db(); dataset ds = new dataset(); public void datalistbind() { sqlstr = "select * from ordermenu where customername='" + session["username"] + "'"; //ds = db.getdatatablebysql(sqlstr); dataset das = dataoperator.getrows(sqlstr); datalist1.datasource = das; datalist1.databind(); //try //{ // this.datalist1.datasource = ds.tables[0].defaultview; // this.datalist1.databind(); //} //catch (exception) //{ // response.write("<script>alert('没有得到数据,请重试!')</script>"); //} } protected void page_load(object sender, eventargs e) { if (page.ispostback == false) { sqlstr = "select * from ordermenu"; ds = db.getdatatablebysql(sqlstr); //try //{ // if (ds.tables[0].rows.count != 0)//若购物车有此产品则提示用户 // { // response.write("<script>alert('你已经购买了此产品,只要更改数量就行!')</script>"); // } // else//若购物车没有此产品则将此产品的相关信息插入购物车 // { // response.write("没有!!"); // } //} //catch (exception) //{ // response.write("<script>alert('没有得到数据,请重试!')</script>"); //} datalistbind();//绑定数据 //total_money();//计算价格 } } protected void shoppingbtn_click(object sender, eventargs e) { response.redirect("ordermainmenu.aspx"); } protected void delallbtn_click(object sender, eventargs e) { } protected void orderbtn_click(object sender, eventargs e) { response.redirect("menuorder.aspx"); } protected void datalist1_deletecommand(object source, datalistcommandeventargs e) { //string book_id = this.datalist1.datakeys[e.item.itemindex].tostring(); //sqlstr = "delete from 购物车表 where 图书编号='" + book_id + "'"; //boolean del_result; //del_result = db.updatedatabysql(sqlstr); //if (del_result == true) //{ // response.write("<script>alert('记录删除成功!')</script>"); // datalistbind();//绑定数据 // total_money();//计算价格 //} //else // response.write("<script>alert('记录删除失败,请检查!')</script>"); } protected void datalist1_updatecommand(object source, datalistcommandeventargs e) { string book_id = this.datalist1.datakeys[e.item.itemindex].tostring(); textbox count = (textbox)this.datalist1.items[e.item.itemindex].findcontrol("txtcount"); string sqlstr1 = "select * from menus where menunumber='" + session["menu_number"] + "'"; ds = dataoperator.getrows(sqlstr1); if (ds.tables[0].rows.count>0) { int pric = convert.toint32(ds.tables[0].rows[0][6]); int mon = convert.toint32(count.text) * pric; //session["paymon"] = mon.tostring(); //total_money_txt.text = mon.tostring(); sqlstr = "update ordermenu set number='" + convert.toint32(count.text) + "',paymoney='" + mon + "' where id='" + book_id + "'"; boolean update_result; update_result = db.updatedatabysql(sqlstr); if (update_result == true) { response.write("<script>alert('数量修改成功!')</script>"); datalistbind();//绑定数据 // total_money();//计算价格 } else response.write("<script>alert('数量修改失败,请检查!')</script>"); } else { } } }
[asp/basic]代码
//menuorder.aspx protected void page_load(object sender, eventargs e) { if (page.ispostback == false) { //session["username"] = "ning"; // datagridviewbind(); //total_money(); string sql = "select * from menuview where customername='" + session["username"] + "'"; ds = dataoperator.getrows(sql); int i = ds.tables[0].rows.count; int tem = 0; for (int j = 0; j < i; j++) { tem = convert.toint32(ds.tables[0].rows[j][5].tostring()) + tem; } total_money_txt.text = tem.tostring(); } } protected void orderbtn_click(object sender, eventargs e) { string sql = "select * from menuview where customername='" + session["username"] + "'"; ds = dataoperator.getrows(sql); int i = ds.tables[0].rows.count; string strgoodid=""; string strcustomername = ""; string strmenuname = ""; string strnumber = ""; string deldate = ""; int strpaymoney = 0; if (i > 0) { bool te = false; for (int j = 0; j < i; j++) { strgoodid = ds.tables[0].rows[j][0].tostring(); strcustomername = ds.tables[0].rows[j][1].tostring(); strmenuname = ds.tables[0].rows[j][2].tostring(); strnumber = ds.tables[0].rows[j][3].tostring(); deldate = ds.tables[0].rows[j][4].tostring(); strpaymoney = convert.toint32(ds.tables[0].rows[j][5]); tem++; string songdate = calendar1.selecteddate.tostring(); string stylepay = ddlpayment.selectedvalue.tostring(); string sakmenu = remarktxtbox.text; string sqlind = "insert into indentmenu values('" + strgoodid + "','" + strcustomername + "','" + strmenuname + "','" + strnumber + "','" + deldate + "','" + strpaymoney + "','" + songdate + "','" + stylepay + "','" + sakmenu + "')"; te = dataoperator.exsql(sqlind); } if (te) { messagebox.showpath("menuindent.aspx"); } else { messagebox.show("存储错误.."); } } else { messagebox.show("出错了啊!!"); } }
以上就是asp.net餐饮管理系统制作关键代码,代码不够完整,本文的目的只是想给大家一个启发,制作餐饮管理系统的思路,希望能真正的帮助到大家。
推荐阅读
-
ASP.NET餐饮管理系统制作代码分享
-
ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统之前端页面框架构建源码分享
-
ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统之前端页面框架构建源码分享
-
ASP.NET MVC通用权限管理系统源代码开源发布(AngelRM_MVC)v2.1
-
理财产品信息管理系统项目代码分享
-
基于Asp.Net Core 2.1的简单问答社区系统源代码分享
-
Bootstrap Table搭建后台管理系统代码分享
-
ASP.NET MVC通用权限管理系统源代码开源发布(AngelRM_MVC)v2.1
-
基于Asp.Net Core 2.1的简单问答社区系统源代码分享
-
Bootstrap Table搭建后台管理系统代码分享