Exemplo n.º 1
0
 protected void WaiterInsert_Click(object sender, EventArgs e)
 {
     //inline version of using MessageUserControl
     MessageUserControl.TryRun(() =>
                               //remainder of the code is what would have gone in the external method of
                               //(ProcessRequest(MethodName))
     {
         Waiter item    = new Waiter();
         item.FirstName = FirstName.Text;
         item.LastName  = LastName.Text;
         item.Address   = Address.Text;
         item.Phone     = Phone.Text;
         item.HireDate  = DateTime.Parse(HireDate.Text);
         //What about nullable field
         if (string.IsNullOrEmpty(ReleaseDate.Text))
         {
             item.ReleaseDate = null;
         }
         else
         {
             item.ReleaseDate = DateTime.Parse(ReleaseDate.Text);
         }
         AdminController sysmgr = new AdminController();
         WaiterID.Text          = sysmgr.Waiters_Add(item).ToString();
         MessageUserControl.ShowInfo("Waiter added.");
         WaiterList.DataBind();
         RefreshWaiterList(WaiterID.Text);
     }
                               );
 }
Exemplo n.º 2
0
    public void InsertWaiterInfo()
    {
        //the code that exsits withen this method is a standered CRUD insert form AppDev1
        eRestaurantController controller = new eRestaurantController();

        //load an instance of contorller
        Waiter item = new Waiter();

        item.WaiterID  = 0;//identity feild for SQL therefore set to 0
        item.FirstName = FirstName.Text;
        item.LastName  = LastName.Text;
        item.Phone     = Phone.Text;
        item.Address   = Address.Text;
        item.HireDate  = DateTime.Parse(HiredDate.Text);
        if (string.IsNullOrEmpty(ReleaseDate.Text))
        {
            item.ReleaseDate = null;
        }
        else
        {
            item.ReleaseDate = DateTime.Parse(ReleaseDate.Text);
        }

        //call the controller's add method for the waiter
        controller.Waiter_Add(item);

        //rebind the drop down list (WaiterList) so the new waiter will appear in the list
        WaiterList.DataBind();
    }
Exemplo n.º 3
0
    //UPDATE
    public void UpdateWaiterInfo()
    {
        //The code that exists within this method is a standard CRUD update.
        //Similar to what was learned in APPDEV 1
        eRestaurantController controller = new eRestaurantController();

        //Load an instance of Waiter.
        Waiter updateWaiter = new Waiter();

        updateWaiter.WaiterID = int.Parse(WaiterList.SelectedValue);

        updateWaiter.FirstName = FirstName.Text;
        updateWaiter.LastName  = LastName.Text;
        updateWaiter.Phone     = Phone.Text;
        updateWaiter.Address   = Address.Text;
        updateWaiter.HireDate  = DateTime.Parse(HiredDate.Text);

        //Check if the release date is Null/Empty
        if (string.IsNullOrEmpty(ReleaseDate.Text))
        {
            updateWaiter.ReleaseDate = null;                                                        //This can be null becuase in the database it is set to "Nullable"
        }
        else
        {
            updateWaiter.ReleaseDate = DateTime.Parse(ReleaseDate.Text);
        }

        //Add waiter to the database.
        controller.Waiter_Update(updateWaiter);

        //Rebind the dropdown (WaiterList) so the new entry will appear in the list.
        WaiterList.DataBind();
    }
Exemplo n.º 4
0
    protected void RefreshWaiterList(string selectedvalue)
    {
        //force a requery of
        WaiterList.DataBind();

        WaiterList.Items.Insert(0, "Select waiter");
        WaiterList.SelectedValue = selectedvalue;
    }
Exemplo n.º 5
0
 protected void  RefreshwaiterList(String selectedValue)
 {
     // force a requery of the dropdown list
     WaiterList.DataBind();
     WaiterList.Items.Insert(0, "Select a Waiter");
     //position on a waiter in the list
     WaiterList.SelectedValue = selectedValue;
 }
Exemplo n.º 6
0
 protected void RefreshWaiterList(string selectedvalue)
 {
     //force the re-execution of the query for the drop down list
     WaiterList.DataBind();
     //insert the prompt line into the drop down list
     WaiterList.Items.Insert(0, "Select a waiter");
     //position the WaiterList to the desired row reprenenting the waiter
     WaiterList.SelectedValue = selectedvalue;
 }
Exemplo n.º 7
0
 protected void RefreshWaiterList(string selectedvalue)
 {
     //force a requery of the DDL
     WaiterList.DataBind();
     //insert the prompt line
     WaiterList.Items.Insert(0, "Select a Waiter");
     //position on a waiter in the list
     WaiterList.SelectedValue = selectedvalue;
 }
Exemplo n.º 8
0
    protected void RefreshWaiterList(String selectedvalue) //2015.10.21

    {
        //force the re-execution of the query for the drop down list
        WaiterList.DataBind(); //databind and evalbind()?
        // insert the prompt line into the drop down list data
        WaiterList.Items.Insert(0, "Select a waiter");
        // position the waiterlist to the desired row representing the waiter
        WaiterList.SelectedValue = selectedvalue;
    }
    protected void RefreshWaiterList(string selectedvalue)
    {
        //force the re-execution for the dropdown list

        WaiterList.DataBind();

        // Insert the prompt line into the dropdown list data
        WaiterList.Items.Insert(0, "Select a Waiter");

        //Position the waiter list to the Desired row representing the waiter
        WaiterList.SelectedValue = selectedvalue;
    }
Exemplo n.º 10
0
 protected void WaiterUpdate_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(WaiterID.Text))
     {
         MessageUserControl.ShowInfo("Please selece a waiter first before update.");
     }
     else
     {
         //standard update process
         MessageUserControl.TryRun(() =>
                                   //remainder of the code is what would have gone in the external method of
                                   //(ProcessRequest(MethodName))
         {
             Waiter item = new Waiter();
             //for an update you must supply the pkey value
             item.WaiterID  = int.Parse(WaiterID.Text);
             item.FirstName = FirstName.Text;
             item.LastName  = LastName.Text;
             item.Address   = Address.Text;
             item.Phone     = Phone.Text;
             item.HireDate  = DateTime.Parse(HireDate.Text);
             //What about nullable field
             if (string.IsNullOrEmpty(ReleaseDate.Text))
             {
                 item.ReleaseDate = null;
             }
             else
             {
                 item.ReleaseDate = DateTime.Parse(ReleaseDate.Text);
             }
             AdminController sysmgr = new AdminController();
             sysmgr.Waiters_Update(item);
             MessageUserControl.ShowInfo("Waiter updated.");
             WaiterList.DataBind();
             RefreshWaiterList(WaiterID.Text);
         }
                                   );
     }
 }
Exemplo n.º 11
0
 protected void RefreshWaiterList(string selectedvalue)
 {
     WaiterList.DataBind();
     WaiterList.Items.Insert(0, "Select a waiter");
     WaiterList.SelectedValue = selectedvalue;
 }