Esempio n. 1
0
    protected void SeatingGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        //extract the table number, number in party and the waiter ID
        //from the grid view
        //we will also create the time from the MockDateTime controls at the top of this form
        //Typically you would use DateTime.Today for current datetime

        //once the date is collected then it will be sent to the BLL for processing

        //the command will be done under the control of the MessageUserControl
        //so if there is an error, the MUC can handle it.
        //we will use the in-line MUC TryRun technique

        MessageUserControl.TryRun(() =>
            {
                //obtain the selected gridview row
                GridViewRow agvrow = SeatingGridView.Rows[e.NewSelectedIndex];
                //accessing a web control on the gridview row uses .FindControl("xxx) as 
                //datatype xxx be the name of control
                //points to the control
                string tablenumber = (agvrow.FindControl("TableNumber") as Label).Text;
                string numberinparty = (agvrow.FindControl("NumberInParty") as TextBox).Text;
                string waiterid = (agvrow.FindControl("WaiterList") as DropDownList).SelectedValue;
                DateTime when = Mocker.MockDate.Add(Mocker.MockTime); //Parse(SearchDate.Text).Add(TimeSpan.Parse(SearchTime.Text));

                //standard call to insert a record into the DB
                AdminController sysmgr = new AdminController();
                sysmgr.SeatCustomer(when, byte.Parse(tablenumber), int.Parse(numberinparty),
                                      int.Parse(waiterid));
                //refresh the gridview
                SeatingGridView.DataBind();
            }, "Customer Seated", "New walk-in customer has been saved"); //message
    }
Esempio n. 2
0
 protected void ReservationSummaryListView_OnItemCommand(object sender, ListViewCommandEventArgs e)
 {
     // Check the command name and add the reservation for the specified seats.
     if (e.CommandName.Equals("Seat"))
     {
         MessageUserControl.TryRun(() =>
         {
             // Get the data
             var reservationId = int.Parse(e.CommandArgument.ToString());
             var selectedItems = new List <byte>();
             foreach (ListItem item in ReservationTableListBox.Items)
             {
                 if (item.Selected)
                 {
                     selectedItems.Add(byte.Parse(item.Text.Replace("Table ", "")));
                 }
             }
             var when = DateTime.Parse(SearchDate.Text).Add(TimeSpan.Parse(SearchTime.Text));
             // Seat the reservation customer
             var controller = new SeatingController();
             controller.SeatCustomer(when, reservationId, selectedItems, int.Parse(WaiterDropDownList.SelectedValue));
             // Refresh the gridview
             SeatingGridView.DataBind();
         }, "Customer Seated", "Reservation customer has arrived and has been seated");
     }
 }
Esempio n. 3
0
    protected void SeatingGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        //extract tablenumber, waiterid, numberinparty from the gridview
        // we will also create a datetime variable using the mock clock at the top of
        //the page. (Typically in real-time you use use DateTime.Today)

        //once the data is collected it will be passed to the BLL from processing

        //the command will be done under the control of the MessageUserControl
        //we will use the MUC inline technique

        MessageUserControl.TryRun(() =>
        {
            //obtain our data from the GridView row
            GridViewRow agvrow = SeatingGridView.Rows[e.NewSelectedIndex];

            //accessing a web control on thee gridview row
            //the command to do this is .FindControl("xxxx") as datatype
            //all data from the gridview is a string
            string tablenumber   = (agvrow.FindControl("TableNumber") as Label).Text;
            string numberinparty = (agvrow.FindControl("NumberInParty") as TextBox).Text;
            string waiterid      = (agvrow.FindControl("WaiterList") as DropDownList).SelectedValue;
            DateTime when        = Mocker.MockDate.Add(Mocker.MockTime);

            //standard typical call to your controller in the BLL
            AdminController sysmgr = new AdminController();
            sysmgr.SeatCustomer(when, byte.Parse(tablenumber),
                                int.Parse(numberinparty),
                                int.Parse(waiterid));

            //refresh the gridview
            SeatingGridView.DataBind();
        }, "Customer Seated", "New walk-in customer has been saved");
    }
Esempio n. 4
0
    protected void ReservationSummaryListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        // this is the method which will gather the seating 
        // information for reservations and pass to the BLL
        // for processing
        
        // no processing will be done unless the e.CommandName is 
        // equal to "Seat"

        if (e.CommandName.Equals.("Seat"))
        {
           // execution of the code will be under the control 
           // of the MessageUserControl
            MessageUserControl.TryRun(() =>
                {
                  //1. gather necessary data from the web controls
                  int reservationid = int.Parse(e.CommandArgument.ToString());
                  int waiterid = int.Parse(WaiterDropDownList.SelectedValue);
                  DateTime when = Mocker.MockDate.Add(Mocker.MockTime);
                  //2. we need to collect possible multiple values
                  // from the ListBox control which contains 
                  // the selected tables to be assigned to this
                  // group of customers
                
                    List<byte> selectedTables = new List<byte>();

                 //3.walk throuth the ListBox row by row
                    foreach (ListItem item_tableid in ReservationTableListBox.Items)
                    {
                       if (item_tableid.Selected)
                       {
                       selectedTables.Add(byte.Parse(item_tableid.Text.Replace("Table ","")));                          )
                                                  
                       }
                                        
                    }

                    //4.with all data gathered, connect to your 
                    //library controller, and send data for 
                    //processing

                    AdminController sysmgr = new AdminController();
                    sysmgr.SeatCustomer(when, reservationid,selectedTables,waiterid);


                    //5.Refresh the page(Screen)
                    SeatingGridView.DataBind();
                    //6.Refresh the reservation Repeater
                    ReservationsRepeater.DataBind();
                    ReservationTableListBox.DataBind();

                },"Customer Seated","Reservation customer has arrived and has been seated");

                       
        
        }

    }
Esempio n. 5
0
    protected void SeatingGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            GridViewRow agvrow = SeatingGridView.Rows[e.NewSelectedIndex];
            //accessing a web control on the girdview row usings .FindControl("xxx") as datatype
            string tablenumber   = (agvrow.FindControl("TableNumber") as Label).Text;
            string numberinparty = (agvrow.FindControl("NumberInParty") as TextBox).Text;
            string waiterid      = (agvrow.FindControl("WaiterList") as DropDownList).SelectedValue;
            var when             = Mocker.MockerDate.Add(Mocker.MockerTime);

            //standard call to insert a record into the database
            AdminController sysmgr = new AdminController();
            sysmgr.SeatCustomer(when, byte.Parse(tablenumber), int.Parse(numberinparty), int.Parse(waiterid));

            SeatingGridView.DataBind();
        }, "Customer Seated", "New walk-in customer has been saved");
    }
Esempio n. 6
0
    protected void ReservationSummaryListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        // this is the method which will gather the seating
        // information for reservations and pass the the BLL for processing
        //no processing will be done unless the e.CoomandName is equal to "Seat"

        if (e.CommandName.Equals("Seat"))
        {
            MessageUserControl.TryRun(() =>
            {
                //gather the necessary data from teh web controls
                int reservationid = int.Parse(e.CommandArgument.ToString());
                int waiterid      = int.Parse(WaiterDropDownList.SelectedValue);
                DateTime when     = Mocker.MockDate.Add(Mocker.MockTime);

                //we need to collect the possible multiple values from the ListBox control which contains the selected tables to be assigned to this group of customer

                List <byte> selectTables = new List <byte>();

                //walk through the lis box row by row
                foreach (ListItem item_tableid in ReservationTableListBox.Items)
                {
                    if (item_tableid.Selected)
                    {
                        selectTables.Add(byte.Parse(item_tableid.Text.Replace("Table ", "")));
                    }
                }


                //with all data gathered. connect to your library controller
                // and send data for processing

                AdminController sysmgr = new AdminController();
                sysmgr.SeatCustomer(when, reservationid, selectTables, waiterid);

                // Refresh the page
                // Refresh both the grid view
                SeatingGridView.DataBind();
                ReservationsRepeater.DataBind();
                ReservationTableListBox.DataBind();
            }, "Customer seated", "Reservation customer has arrvied and has been seated");
        }
    }
Esempio n. 7
0
 protected void SeatingGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
 {
     // Seat walk-in customers
     MessageUserControl.TryRun(() =>
     {
         // TODO: There are a lot of assumptions in parsing the input, and it would be better
         //       to break this into chunks an display appropriate "usage" messages to the end-user.
         // Get the controls
         GridViewRow row          = SeatingGridView.Rows[e.NewSelectedIndex];
         var tableControl         = row.FindControl("TableNumber") as Label;
         var numberInPartyControl = row.FindControl("NumberInParty") as TextBox;
         var waiterListControl    = row.FindControl("WaiterList") as DropDownList;
         var when = DateTime.Parse(SearchDate.Text).Add(TimeSpan.Parse(SearchTime.Text));
         // Seat the customer
         var controller = new SeatingController();
         controller.SeatCustomer(when, byte.Parse(tableControl.Text), int.Parse(numberInPartyControl.Text), int.Parse(waiterListControl.SelectedValue));
         // Refresh the gridview
         SeatingGridView.DataBind();
     }, "Customer Seated", "New walk-in customer has been seated");
 }