Home>

Page introduction display:

The above is a picture introduction of the restaurant management system.The next part is the code.

menu.aspx



<%@page language="c#" masterpagefile="~/masterpage.master" autoeventwireup="true" codefile="menu.aspx.cs" inherits="menu"%>
<asp:content contentplaceholderid="contentplaceholder1" runat="server">
  <form runat="server">
<>
  <asp:gridview runat="server" autogeneratecolumns="false"
    datasourceid="sqldatasource1" height="299px"
    width="544px" allowpaging="true" pagesize="4">
    <pagersettings firstpagetext="first page" lastpagetext="last page"
      mode="nextpreviousfirstlast" nextpagetext="Next page" previouspagetext="Previous Page" />
    <columns>
      <asp:boundfield datafield="menuid" headertext="serial number" insertvisible="false"
        readonly="true" sortexpression="menuid" />
      <asp:boundfield datafield="menuname" headertext="dish name"
        sortexpression="menuname" />
      <asp:imagefield dataimageurlfield="menuphoto" headertext="picture"
         controlstyle-height="30px"
         controlstyle-width="70px"
        sortexpression="menuphoto">
<controlstyle height="30px" width="70px"</controlstyle>
      </asp:imagefield>
      <asp:boundfield datafield="menucooker" headertext="chef"
        sortexpression="menucooker" />
      <asp:boundfield datafield="menustyle" headertext="food"
        sortexpression="menustyle" />
      <asp:boundfield datafield="menuprice" headertext="price"
        sortexpression="menuprice" />
      <asp:boundfield datafield="menudate" headertext="created date"
        sortexpression="menudate" />
    </columns>
  </asp:gridview>
  <asp:sqldatasource runat="server"
    connectionstring="<%$connectionstrings:connstr%>"
    selectcommand="select [menuid], [menuname], [menuphoto], [menucooker], [menustyle], [menuprice], [menudate] from [menus]">
  </asp:sqldatasource>
</>
  </form>
</asp:content>
<asp:content contentplaceholderid="contentplaceholder2" runat="server">
  <>
   <asp:datalist runat="server" datasourceid="sqldatasource2">
   <headertemplate>
    <table border="1">
    <tr>
    <td>Picture</td>
    <td>dish name</td>
    <td>Original Price</td>
    <td>Preferential price</td>
    </tr>
    </headertemplate>
     <itemtemplate>
         <tr>
           <td>
             <asp:image runat="server" height="88px"
               imageurl="<%#eval (" menuphoto ")%>" width="88px" />
           </td>
           <td>
             <asp:label runat="server" text="&%;eval (" menuname ")%>"</asp:label>
           </td>
           <td>
             <asp:label runat="server" text="&%;eval (" menuprice ")%>"</asp:label>
           </td>
           <td>
             <asp:label runat="server" text="&%;eval (" menunewprice ")%>"</asp:label>
           </td>
         </tr>
     </itemtemplate>
     <footertemplate></table></footertemplate>
   </asp:datalist>
   <asp:sqldatasource 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"%>
<asp:content contentplaceholderid="contentplaceholder1" runat="server">
  <form runat="server">
<>
 <table cellspacing="1" cellpadding="0" width="530" align="center" border="0"&​​gt;
          <tr>
            <td align="center">
              <asp:label runat="server" font-size="x-large" font-names="Chinese script" forecolor="blue"
          </tr>
          <tr>
            <td align="center">
            <asp:datalist 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">
          <tr>
            <td>
              Serial number</td>
            <td>
              Dish name</td>
            <td>
              Picture</td>
            <td>
              Paid</td>
            <td>
              Copies</td>
            <td>
              Saved copies</td>
            <td>
              Delete</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 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 runat="server" width="32px"
             text="<%#databinder.eval (container.dataitem," number ")%>"</asp:textbox></td>
         <td><asp:button runat="server" text="Save Modification" commandname="update"></asp:button></td>
         <td><asp:button runat="server" text="delete" commandname="delete" /></td>
        </tr>
      </itemtemplate>
      <footertemplate></table></footertemplate>
      <footerstyle backcolor="tan" />
      </asp:datalist>
      </td>
          </tr>
          <tr>
            <td align="center" height="40">Total amount:
              <asp:textbox runat="server" width="82px"<&/;asp:textbox>
              <asp:button runat="server" text="continue shopping" onclick="shoppingbtn_click"</asp:button>
              <asp:button runat="server" text="Empty Shopping Cart" onclick="delallbtn_click"></asp:button>
              <asp:button runat="server" text="clearing center" 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 (" did not get 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 the cart has this product, it will prompt the user
      //{
      //response.write ("<script>alert (" You have purchased this product,Just change the quantity! ")</script>");
      //}
      //else //If the shopping cart does not have this product, insert the relevant information of this product into the shopping cart
      //{
      //response.write ("No !!");
      //}
      //}
      //catch (exception)
      //{
      //response.write ("<script>alert ("
Please try again! ")</script>");
      //}
      datalistbind ();//Binding 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, datalistcommandeventargs e)
  {
    //string book_id=this.datalist1.datakeys [e.item.itemindex] .tostring ();
    //sqlstr="delete from 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 ();//Binding 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 + book_id +" "";
      boolean update_result;
      update_result=db.updatedatabysql (sqlstr);
      if (update_result == true)
      {
        response.write ("<script>alert (" Quantity modified successfully! ")</script>");
        datalistbind ();//Binding data
      //total_money ();//Calculate the price
      }
      else
        response.write ("<script>alert ("
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.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 ("Storage error.
. ");
      }
    }
    else
    {
      messagebox.show ("What went wrong !!!");
    }
}
  • Previous DataGridView expansion and contraction function implementation
  • Next Android live folder creation method