ASP. NET catering management system production code sharing, asp.net catering management system
Page Introduction:
The above is an introduction to the image production of the catering management system, followed by the Code section.
Menu. aspx
Bytes
<% @ Page Language = "C #" MasterPageFile = "~ /MasterPage. master "AutoEventWireup =" true "CodeFile =" menu. aspx. cs "Inherits =" menu "Title =" untitled page "%> <asp: content ID = "Content1" ContentPlaceHolderID = "ContentPlaceHolder1" Runat = "Server"> <form id = "form1" runat = "server"> <style = "height: 300px "> <asp: gridView ID = "GridView1" runat = "server" AutoGenerateColumns = "False" performanceid = "sqlperformance1" Height = "299px" Width = "544px" AllowPaging = "True" PageSize = "4 "> <PagerSettings FirstPageText =" Homepage "LastPageText =" last page "Mode =" nextpreviusfirstlast "NextPageText =" next page "PreviousPageText =" Previous Page "/> <Columns> <asp: boundField DataField = "menuID" HeaderText = "no." InsertVisible = "False" ReadOnly = "True" SortExpression = "menuID"/> <asp: boundField DataField = "menuName" HeaderText = "Dish name" SortExpression = "menuName"/> <asp: imageField DataImageUrlField = "menuPhoto" HeaderText = "image" ControlStyle-Height = "30px" ControlStyle-Width = "70px" SortExpression = "menuPhoto"> <controlheight = "30px" Width = "70px"> </ControlStyle> </asp: imageField> <asp: BoundField DataField = "menuCooker" HeaderText = "Chef" SortExpression = "menuCooker"/> <asp: boundField DataField = "menuStyle" HeaderText = "" SortExpression = "menuStyle"/> <asp: boundField DataField = "menuPrice" HeaderText = "price" 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" performanceid = "sqlperformance2"> <HeaderTemplate> <table border = "1" style = "width: 104%; height: 36px "> <tr> <td> picture </td> <td> name of the dish </td> <td> original price </td> <td> discount price </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
Usage <% @ 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"> Car ordering </asp: label> </TD> </TR> <TD align = "center"> <asp: dataList ID = "DataList1" runat = "server" BorderColor = "Tan" BorderWidth = "1px" CellPadding = "2" ForeColor = "Black" DataKeyField = "ID" onupdatecommand = "DataList1_UpdateCommand command "OnDeleteCommand =" inherit "AllowPaging =" true "PageSize =" 4 "RepeatColumns =" 4 "> <% -- <AlternatingItemStyle BackColor =" PaleGoldenrod "/> <SelectedItemStyle BackColor =" inherit ""ForeColor =" GhostWhite "/> -- %> <HeaderTemplate> <table border =" 1 "style =" width: 100% "> <tr> <td style =" width: 25px "> NO. </td> <td style =" width: 33px "> name </td> <td style =" width: 49px "> image </td> <td style =" width: 30px "> paid </td> <td> Number of copies </td> <td> Number of saved copies </td> <td> Delete </td> </tr> </HeaderTemplate> <HeaderStyle BackColor = "Tan" Font-Bold = "True"/> <ItemTemplate> <tr> <td> <% # DataBinder. eval (Container. dataItem, "goodID") %> </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> <% # DataBinder. eval (Container. dataItem, "payMoney") %> </td> <asp: textBox ID = "txtCount" runat = "server" Width = "32px" Text = '<% # DataBinder. eval (Container. dataItem, "number") %> '> </asp: TextBox> </td> <asp: button ID = "bnMod" runat = "server" Text = "Save and modify" CommandName = "Update"> </asp: Button> </td> <asp: button ID = "Button1" runat = "server" Text = "Delete" CommandName = "Delete"/> </td> </tr> </ItemTemplate> <FooterTemplate> </ table> </FooterTemplate> <FooterStyle BackColor = "Tan"/> </asp: dataList> </TD> </TR> <TD align = "center" height = "40"> total amount: <asp: textBox id = "total_money_txt" runat = "server" Width = "82px"> </asp: TextBox> <asp: button id = "shoppingbtn" runat = "server" Text = "continue shopping" OnClick = "shoppingbtn_Click"> </asp: Button> <asp: button id = "delallbtn" runat = "server" Text = "clear shopping cart" OnClick = "delallbtn_Click"> </asp: Button> <asp: button id = "orderbtn" runat = "server" Text = "settlement center" OnClick = "orderbtn_Click"> </asp: button> </TD> </TR> <TD align = "center"> </TD> </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. W Rite ("<script> alert ('no data, please try again! ') </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) // if this product is available in the shopping cart, the user is prompted. // {// Response. write ("<script> alert ('you have purchased this product, you just need to change the quantity! ') </Script> "); // else // if this product is not available in the shopping cart, insert the related information of this product into the shopping cart // {// Response. write ("No !! "); //} // Catch (Exception) // {// Response. Write (" <script> alert ('no data, please try again! ') </Script> "); //} DataListBind (); // bind data // total_money (); // calculate the price} 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, DataListCom MandEventArgs e) {// String book_id = this. dataList1.DataKeys [e. item. itemIndex]. toString (); // SqlStr = "delete from shopping cart table where Book Number = '" + book_id + "'"; // Boolean Del_Result; // Del_Result = db. updateDataBySql (SqlStr); // if (Del_Result = true) // {// Response. write ("<script> alert ('record deleted successfully! ') </Script> "); // DataListBind (); // bind data // total_money (); // calculate the price //} // else // Response. write ("<script> alert ('record deletion failed, please check! ') </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 (Upda Te_Result = true) {Response. Write ("<script> alert ('quantity modified successfully! ') </Script> "); DataListBind (); // bind data // total_money (); // calculate the price} else Response. write ("<script> alert ('quantity modification failed, please check! ') </Script> ");} else {}}}
[ASP/Basic] Code
// 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. tabl Es [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 d Eldate = ""; 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. e XSql (sqlind);} if (te) {MessageBox. showPath ("menuIndent. aspx ");} else {MessageBox. show ("Storage error .. ") ;}} else {MessageBox. show ("error !! ");}}
The above is ASP. NET catering management system to make key code, the code is not complete, the purpose of this article is to give you an inspiration, the idea of making a catering management system, hope to truly help everyone.