ASP.NET餐飲管理系統(tǒng)制作代碼分享
頁(yè)面介紹展示:




以上是餐飲管理系統(tǒng)制作圖片介紹,接下來(lái)是代碼部分。
menu.aspx
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="menu.aspx.cs" Inherits="menu" Title="無(wú)標(biāo)題頁(yè)" %>
<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="首頁(yè)" LastPageText="末頁(yè)"
Mode="NextPreviousFirstLast" NextPageText="下一頁(yè)" PreviousPageText="上一頁(yè)" />
<Columns>
<asp:BoundField DataField="menuID" HeaderText="序號(hào)" 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="價(jià)格"
SortExpression="menuPrice" />
<asp:BoundField DataField="menuDate" HeaderText="創(chuàng)菜日期"
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>原價(jià)格</td>
<td>優(yōu)惠價(jià)格</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="無(wú)標(biāo)題頁(yè)" %>
<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">
序號(hào)</td>
<td style="width: 33px">
菜名</td>
<td style="width: 49px">
圖片</td>
<td style="width: 30px">
付費(fèi)</td>
<td>
份數(shù)</td>
<td>
保存份數(shù)</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="繼續(xù)購(gòu)物" OnClick="shoppingbtn_Click"></asp:Button>
<asp:Button id="delallbtn" runat="server" Text="清空購(gòu)物車" OnClick="delallbtn_Click"></asp:Button>
<asp:Button id="orderbtn" runat="server" Text="結(jié)算中心" 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('沒(méi)有得到數(shù)據(jù),請(qǐng)重試!')</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)//若購(gòu)物車有此產(chǎn)品則提示用戶
// {
// Response.Write("<script>alert('你已經(jīng)購(gòu)買了此產(chǎn)品,只要更改數(shù)量就行!')</script>");
// }
// else//若購(gòu)物車沒(méi)有此產(chǎn)品則將此產(chǎn)品的相關(guān)信息插入購(gòu)物車
// {
// Response.Write("沒(méi)有??!");
// }
//}
//catch (Exception)
//{
// Response.Write("<script>alert('沒(méi)有得到數(shù)據(jù),請(qǐng)重試!')</script>");
//}
DataListBind();//綁定數(shù)據(jù)
//total_money();//計(jì)算價(jià)格
}
}
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 購(gòu)物車表 where 圖書編號(hào)='" + book_id + "'";
//Boolean Del_Result;
//Del_Result = db.UpdateDataBySql(SqlStr);
//if (Del_Result == true)
//{
// Response.Write("<script>alert('記錄刪除成功!')</script>");
// DataListBind();//綁定數(shù)據(jù)
// total_money();//計(jì)算價(jià)格
//}
//else
// Response.Write("<script>alert('記錄刪除失敗,請(qǐng)檢查!')</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('數(shù)量修改成功!')</script>");
DataListBind();//綁定數(shù)據(jù)
// total_money();//計(jì)算價(jià)格
}
else
Response.Write("<script>alert('數(shù)量修改失敗,請(qǐng)檢查!')</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("存儲(chǔ)錯(cuò)誤..");
}
}
else
{
MessageBox.Show("出錯(cuò)了?。?!");
}
}
以上就是ASP.NET餐飲管理系統(tǒng)制作關(guān)鍵代碼,代碼不夠完整,本文的目的只是想給大家一個(gè)啟發(fā),制作餐飲管理系統(tǒng)的思路,希望能真正的幫助到大家。
- ASP.NET MVC5+EF6+EasyUI 后臺(tái)管理系統(tǒng)(81)-數(shù)據(jù)篩選(萬(wàn)能查詢)實(shí)例
- Elasticsearch.Net使用教程 MVC4圖書管理系統(tǒng)(2)
- ASP.NET MVC5+EF6+EasyUI后臺(tái)管理系統(tǒng) 微信公眾平臺(tái)開(kāi)發(fā)之資源環(huán)境準(zhǔn)備
- ASP.NET MVC5+EF6+EasyUI后臺(tái)管理系統(tǒng) 微信公眾平臺(tái)開(kāi)發(fā)之消息管理
- ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后臺(tái)管理系統(tǒng)之前端頁(yè)面框架構(gòu)建源碼分享
- ASP.NET實(shí)現(xiàn)學(xué)生管理系統(tǒng)
- ASP.NET網(wǎng)站管理系統(tǒng)退出 清除瀏覽器緩存,Session的代碼
- Asp.Net權(quán)限管理系統(tǒng) 專用代碼生成工具(DDBuildTools) 1.1.0 下載
- .NET實(shí)現(xiàn)工資管理系統(tǒng)
相關(guān)文章
C#和asp.net中鏈接數(shù)據(jù)庫(kù)中參數(shù)的幾種傳遞方法實(shí)例代碼
這篇文章介紹了C#和asp.net中鏈接數(shù)據(jù)庫(kù)中參數(shù)的幾種傳遞方法實(shí)例代碼,有需要的朋友可以參考一下2013-10-10
ASP.NET一次性對(duì)GridView批量更新多行數(shù)據(jù)
這篇文章介紹了ASP.NET一次性對(duì)GridView批量更新多行數(shù)據(jù)的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-05-05
ASP.NET使用gridview獲取當(dāng)前行的索引值
這篇文章主要介紹了ASP.NET使用gridview獲取當(dāng)前行的索引值的方法匯總,有需要的小伙伴可以參考下。2015-06-06
使用ASP.NET?Web?API構(gòu)建Restful?API
這篇文章介紹了使用ASP.NET?Web?API構(gòu)建Restful?API的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-04-04
Visual Studio 2019 使用 Live Share的教程圖解
Visual Studio 2019 在今天發(fā)布(北京時(shí)間)了,這次帶來(lái)了一個(gè)比較有趣的 Live Share 功能,使用它可以進(jìn)行更好的協(xié)作開(kāi)發(fā)。這篇文章主要介紹了Visual Studio 2019 使用 Live Share的教程,需要的朋友可以參考下2019-04-04
C# 無(wú)限級(jí)分類的實(shí)現(xiàn)
采用存儲(chǔ)過(guò)程實(shí)現(xiàn)遞歸邏輯,直接返回子分類列表的方式應(yīng)該有更好的性能,尤其是Web服務(wù)器與數(shù)據(jù)庫(kù)服務(wù)器不位于同一臺(tái)服務(wù)器上時(shí),更會(huì)受網(wǎng)絡(luò)影響。2009-02-02
Ubuntu16.04系統(tǒng)配置.net core環(huán)境
本文給大家介紹的是在Ubuntu16.04系統(tǒng)配置.net core環(huán)境的方法,由于作者本身用的是WIN系統(tǒng),所以這次教程是在VMware中進(jìn)行的,希望大家能夠喜歡。2016-07-07
asp.net中for和do循環(huán)語(yǔ)句用法分享
文章介紹了兩個(gè)實(shí)例一個(gè)是FOR循環(huán)創(chuàng)建一個(gè)Mandelbrot圖像,循環(huán)結(jié)構(gòu)之DO語(yǔ)句,根據(jù)布爾值的測(cè)試結(jié)果,執(zhí)行相應(yīng)代碼,有需要的朋友可參考一下2012-04-04

