Asp. NET Catering management System Production Code sharing _ practical skills

Source: Internet
Author: User
Tags eval connectionstrings

Page Introduction Display:

Above is the food management system to make the picture introduction, Next is the Code section.

Menu.aspx



<%@ Page language= "C #" masterpagefile= "~/masterpage.master" autoeventwireup= "true" codefile= "Menu.aspx.cs" Inherits= "Menu" title= "Untitled page"%> <asp:content id= "Content1" contentplaceholderid= "ContentPlaceHolder1"  Server > <form id= "Form1" runat= "Server" > < style= "height:300px" > <asp:gridview id= "GridView1" runat= "Server" autogeneratecolumns= "False" datasourceid= "SqlDataSource1" height= "299px" width= "544px" ALLOWPA ging= "True" pagesize= "4" > <pagersettings firstpagetext= "Home" lastpagetext= "last" mode= "Nextpreviousfirstla St "nextpagetext=" Next "previouspagetext=" prev "/> <Columns> <asp:boundfield datafield=" MenuID "head ertext= "ordinal" insertvisible= "False" readonly= "True" sortexpression= "MenuID"/> <asp:boundfield Eld= "MenuName" headertext= "menu name" sortexpression= "MenuName"/> <asp:imagefield "menu Photo "headertext=" Picture "controlstyle-height= "30px" controlstyle-width= "70px" sortexpression= "Menuphoto" > <controlstyle Heig ht= "30px" width= "70px" ></ControlStyle> </asp:ImageField> <asp:boundfield datafield= "Menuco Oker "headertext=" Chef sortexpression= "Menucooker"/> <asp:boundfield datafield= "Menustyle" HeaderTe  
        xt= "Cuisine" sortexpression= "Menustyle"/> <asp:boundfield datafield= "Menuprice" headertext= "Price" sortexpression= "Menuprice"/> <asp:boundfield datafield= "menudate" headertext= "Creation date" SortExpress ion= "Menudate"/> </Columns> </asp:GridView> <asp:sqldatasource id= "SqlDataSource1" runat= "se RVer "connectionstring=" <%$ connectionstrings:connstr%> "selectcommand=" SELECT [MenuID], [MenuName], [m  
  Enuphoto], [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" >  

menucar.aspx

<%@ Page language= "C #" masterpagefile= "~/land-zhuce.master" autoeventwireup= "true" codefile= "MenuCar.aspx.cs" inherits= "Menucar" title= "Untitled page"%> <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 "Center" 
              ; <asp:label id= "Label1" runat= "Server" font-size= "X-large" font-names= "Chinese Xingkai" forecolor= "Blue" > Order Dining car </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 Backcolo 
      R= "Palegoldenrod"/> <selecteditemstyle backcolor= "Darkslateblue" forecolor= "Ghostwhite"/>--%> <HeaderTemplate> <table border= "1" style= "width:100%" > <tr> < TD style= "WIDTH:25PX" > Serial number </td> <td style= "width:33px" > Vegetable name </ td> <td style= "width:49px" > Pictures </td> <td style= "width:30px" 
              ; 
            Paid </td> <td> copies </td> <td> save number </td> 
      <td> Delete </td> </tr> </HeaderTemplate>  

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 the 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 shopping cart has this product then prompts the user//{//Response.Write ("<script>alert (' you have purchased this product, as long as the number of changes on the line!") 
      ') </script> "); //else//If the cart does not have this product, insert information about this product into the cart//{//Response.Write ("No!!") 
      "); }//}//catch (Exception)//{//Response.Write ("<script>alert" (' No data, please try again!) 
      ') </script> "); Datalistbind ()//Bound data//total_money ();//Calculate Price}} protected void Shoppingbtn_click (Object sen 
  Der, 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 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 deletion succeeded!) 
    ') </script> "); ' 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 (Update_result = = True) {Response.Write ("<script>alert") (' Number modified successfully! 
        ') </script> "); Datalistbind ()//Bind data//Total_money ();//Calculate 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.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 + "', '" + st 
        Rnumber + "', '" + deldate + "', '" + Strpaymoney + "', '" + songdate + "', '" + Stylepay + "', '" + Sakmenu + "'); 
         
      Te = Dataoperator.exsql (sqlind); } if (TE) {MessageBox.Showpath ("menuindent.aspx"); 
      else {MessageBox.Show ("store error ..."); } else {MessageBox.Show ("Wrong!!!!!!!!!     
    ");  } 
}

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 production of food management system ideas, hoping to really help everyone.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.