Ejemplo n.º 1
0
    protected void UpdateWaiter_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(WaiterID.Text))
        {
            MessageUserControl1.ShowInfo("Please select a waiter to update");
        }
        else
        {
            MessageUserControl1.TryRun(() =>
            {
                Waiter item    = new Waiter();
                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(DateHired.Text);
                if (string.IsNullOrEmpty(DateReleased.Text))
                {
                    item.ReleaseDate = null;
                }
                else
                {
                    item.ReleaseDate = DateTime.Parse(DateReleased.Text);
                }

                AdminController sysmgr = new AdminController();
                sysmgr.Waiter_Update(item);
                MessageUserControl1.ShowInfo("Waiter Updated");
                RefreshwaiterList(WaiterID.Text);
            }
                                       );
        }
    }
Ejemplo n.º 2
0
 protected void Search_Click(object sender, EventArgs e)
 {
     AlbumID.Text             = "";
     AlbumTitle.Text          = "";
     AlbumReleaseYear.Text    = "";
     AlbumReleaseLabel.Text   = "";
     ArtistList.SelectedIndex = 0;
     if (string.IsNullOrEmpty(SearchArg.Text))
     {
         MessageUserControl1.ShowInfo("Enter an album title or part of the title.");
     }
     else
     {
         MessageUserControl1.TryRun(() =>
         {
             AlbumController sysmgr = new AlbumController();
             List <Album> albumlist = sysmgr.Albums_GetbyTitle(SearchArg.Text);
             if (albumlist.Count == 0)
             {
                 MessageUserControl1.ShowInfo("Search Result", "No data for album title or partial title " + SearchArg.Text);
                 AlbumList.DataSource = null;
                 AlbumList.DataBind();
             }
             else
             {
                 MessageUserControl1.ShowInfo("Search Result", "Select the desired album for maintanence");
                 AlbumList.DataSource = albumlist;
                 AlbumList.DataBind();
             }
         });
     }
 }
Ejemplo n.º 3
0
 protected void FetchWaiter_Click(object sender, EventArgs e)
 {
     if (WaiterList.SelectedIndex == 0)
     {
         MessageUserControl1.ShowInfo("Please select a waiter before clicking Fetch Waiter.");
     }
     else
     {
         //we will use a TryCatch() from the MessageUserControl. This will capture error messages when/if they happen, and properly display in the user control.
         MessageUserControl1.TryRun((ProcessRequest)GetWaiterInfo);
     }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.IsAuthenticated && (User.IsInRole("RaceCoordinator") || User.IsInRole("Administrators")))
     {
         MessageUserControl1.ShowInfo(User.Identity.Name, "You've successfully logged in");
     }
     else
     {
         Response.Redirect("~/Account/Login.aspx");
     }
     Label4.Text = User.Identity.Name;
 }
Ejemplo n.º 5
0
 protected void FetchWaiter_Click(object sender, EventArgs e)
 {
     if (WaiterList.SelectedIndex == 0)
     {
         MessageUserControl1.ShowInfo("Please select a waiter before clicking 'Fetch Waiter'.");
     }
     else
     {
         //we will use a TryRun() from the MessageUserControl
         //this will capture error messages when/if they happen and properly display in the user control
         //GetWaiterInfo is your mehtod for accessing BLL and query
         MessageUserControl1.TryRun((ProcessRequest)GetWaiterInfo);
     }
 }
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "CustomUpdate")
            {
                string       error        = string.Empty;
                var          controller   = new RacingController();
                int          index        = Convert.ToInt32(e.CommandArgument);
                HiddenField  raceId       = (HiddenField)GridView1.Rows[index].FindControl("RaceID");
                TextBox      comment      = (TextBox)GridView1.Rows[index].FindControl("RaceDetailComment");
                DropDownList car          = (DropDownList)GridView1.Rows[index].FindControl("CarDropDown");
                HiddenField  raceDetailID = (HiddenField)GridView1.Rows[index].FindControl("RaceDetailID");
                CheckBox     refund       = (CheckBox)GridView1.Rows[index].FindControl("RefundCheckBox");
                TextBox      refundReason = (TextBox)GridView1.Rows[index].FindControl("RefundTextBox");

                RosterViewModel roster = new RosterViewModel()
                {
                    CarID             = int.Parse(car.SelectedValue),
                    RaceDetailComment = comment.Text,
                    RefundReason      = refundReason.Text,
                    Refund            = refund.Checked,
                    RaceDetailID      = int.Parse(raceDetailID.Value)
                };

                if (refund.Checked && refundReason.Text.Trim().Length == 0)
                {
                    error = error + " A reason must be provided for all refunds";
                }

                if (error.Trim().Length == 0)
                {
                    try
                    {
                        controller.Edit_Roster(roster);
                    } catch (Exception ex)
                    {
                        MessageUserControl1.ShowInfo(ex.Message, "Failed to update details");
                    }
                    MessageUserControl1.ShowInfo("Success", "RaceDetails Updated");
                    GridView1.EditIndex = -1;
                    GridView1.DataBind();
                }
                else
                {
                    MessageUserControl1.ShowInfo("Error", error);
                }
            }
        }
Ejemplo n.º 7
0
 protected void InsertWaiter_Click(object sender, EventArgs e)
 {
     //this example is using the TryRun inline
     MessageUserControl1.TryRun(() =>
     {
         Waiter item            = new Waiter();
         item.FirstName         = FirstName.Text;
         item.LastName          = LastName.Text;
         item.Address           = Address.Text;
         item.Phone             = Phone.Text;
         item.HireDate          = DateTime.Parse(DateHired.Text);
         item.ReleaseDate       = null;
         AdminController sysmgr = new AdminController();
         WaiterID.Text          = sysmgr.Waiter_Add(item).ToString();
         MessageUserControl1.ShowInfo("Waiter Added.");
         RefreshWaiterList(WaiterID.Text);
     });
 }
Ejemplo n.º 8
0
    protected void Search_Click(object sender, EventArgs e)
    {
        //clear out the old album information on the Maintain tab
        Clear_Click(sender, e);

        if (string.IsNullOrEmpty(SearchArg.Text))
        {
            //(message string)
            MessageUserControl1.ShowInfo("Enter an album title or part of the title.");
        }
        else
        {
            //do a look of the data in the db via the controller
            //all actions that are external to the webpage should be done in a try/catch
            //   for friendly error handling
            //we will use MessageUserControl to handle the error messages for this semester
            MessageUserControl1.TryRun(() =>
            {
                //coding block I wish MessageUserControl to try and run checking for
                //any errors, catching the errors, and displaying said error(s) for me
                //in its error panel
                //what is leave for me to do: simply the logic for the event

                //standard lookup
                AlbumController sysmgr = new AlbumController();
                List <Album> albumlist = sysmgr.Albums_GetbyTitle(SearchArg.Text);
                if (albumlist.Count == 0)
                {
                    //(title string, message string)
                    MessageUserControl1.ShowInfo("Search Result",
                                                 "No data for album title or partial tile " + SearchArg.Text);
                    AlbumList.DataSource = null;
                    AlbumList.DataBind();
                }
                else
                {
                    MessageUserControl1.ShowInfo("Search Result",
                                                 "Select the desired album for maintenance.");
                    AlbumList.DataSource = albumlist;
                    AlbumList.DataBind();
                }
            });
        }
    }
Ejemplo n.º 9
0
    protected void Search_Click(object sender, EventArgs e)
    {
        //Clear out the old album information on the maintain tab.
        Clear_Click(sender, e);
        if (string.IsNullOrEmpty(SearchArg.Text))
        {
            MessageUserControl1.ShowInfo("Please Enter an Album Title or part of the title");
        }
        else
        {
            //Lookup of the data in the database.We are the controller all actions all the external to the
            //web page should be done through a try catch. From a friendly error handling.
            //We will use the mesageusercotrol to handle error messages for this semester.
            MessageUserControl1.TryRun(() =>
            {
                //Coding block I wish message user control to try and run and check the checking for
                //any errors catching the errors and displaying set errors sfor me in its error panel.
                //What is left for me to do is simply the logicc for me to do the event.

                //This is a standard lookup
                AlbumController sysmgr = new AlbumController();
                List <Album> albumlist = sysmgr.Albums_GetbyTitle(SearchArg.Text);
                if (albumlist.Count == 0)
                {
                    //Title String,message string
                    MessageUserControl.ShowInfo("Search Result",
                                                "No data for the album title or the partial title  " + SearchArg.Text);
                    AlbumList.DataSource = null;
                    AlbumList.DataBind();
                }
                else
                {
                    MessageUserControl.ShowInfo("Using Instructions",
                                                "Select the desired album for the maintenece.");
                    AlbumList.DataSource = albumlist;
                    AlbumList.DataBind();
                }
            }
                                       );
        }
    }
Ejemplo n.º 10
0
 protected void CheckforException(object sender, ObjectDataSourceStatusEventArgs e)
 {
     MessageUserControl1.HandleDataBoundException(e);
 }
Ejemplo n.º 11
0
 protected void checkForException(object sender, ObjectDataSourceStatusEventArgs e)
 {
     MessageUserControl1.HandleDataBoundException(e); //MessageUserControl1 is The name of MessageUserControl
 }
        protected void SaveButton_Command(object sender, CommandEventArgs e)
        {
            string      error      = string.Empty;
            var         controller = new RacingController();
            HiddenField raceId     = null;

            foreach (GridViewRow row in GridView1.Rows)
            {
                raceId = (HiddenField)row.FindControl("RaceID");
            }
            DropDownList memberDropDown = (DropDownList)GridView1.FooterRow.FindControl("MemberDropDown");
            DropDownList feeDropDown    = (DropDownList)GridView1.FooterRow.FindControl("FeeDropDown");
            DropDownList carDropDown    = (DropDownList)GridView1.FooterRow.FindControl("SerialDropDown");

            decimal raceFee;

            if (feeDropDown.SelectedIndex == 1)
            {
                TextBox feeTextBox = (TextBox)GridView1.FooterRow.FindControl("FeeTextBox");
                raceFee = int.Parse(feeTextBox.Text);
            }
            else if (feeDropDown.SelectedIndex == 0)
            {
                raceFee = 0;
            }
            else
            {
                raceFee = decimal.Parse(feeDropDown.SelectedItem.Text);
            }

            RosterViewModel roster = new RosterViewModel()
            {
                MemberID = int.Parse(memberDropDown.SelectedValue),
                CarID    = int.Parse(carDropDown.SelectedValue),
                RaceID   = int.Parse(raceId.Value),
                RaceFee  = raceFee
            };
            var racerCount           = controller.Racer_Count(roster);
            InvoiceViewModel invoice = null;

            if (memberDropDown.SelectedIndex == 0)
            {
                error = error + " You must select a member when adding a new racer.";
            }

            if (raceFee == 0)
            {
                error = error + " You must enter a race fee in order to add a new racer.";
            }

            if (racerCount.Current > racerCount.Max)
            {
                error = error + " Race is already full.  Cannot register additional racers.";
            }

            if (error.Trim().Length == 0)
            {
                try
                {
                    invoice = controller.Add_Racer(roster, User.Identity.Name);
                } catch (Exception ex)
                {
                    MessageUserControl1.ShowInfo(ex.Message, "Unable to save racer");
                }

                var updateSchedule = controller.Schedules_List(Calendar1.SelectedDate);

                RosterDataSource.SelectParameters.Clear();
                RosterDataSource.SelectParameters.Add(new Parameter("raceId", TypeCode.Int32, raceId.Value));
                RosterDataSource.DataBind();

                ScheduleGridView.DataSource = updateSchedule;
                ScheduleGridView.DataBind();

                MessageUserControl1.ShowInfo("Success", ($"Racer Added to roster.  Invoice #{invoice.InvoiceID} created by {User.Identity.Name}.  Subtotal - {invoice.Subtotal:C2}, GST - {invoice.GST:C2}, Total - {invoice.Total:C2}"));
            }
            else
            {
                MessageUserControl1.ShowInfo("Failure", error);
            }
            CloseFooter();
        }
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            RosterViewModel raceData   = (RosterViewModel)e.Row.DataItem;
            var             controller = new RacingController();

            if (raceData != null)
            {
                if (raceData.RaceDetailID == 0)
                {
                    LinkButton editButton = (LinkButton)e.Row.FindControl("LinkButton1");
                    CheckBox   refund     = (CheckBox)e.Row.FindControl("CheckBox1");
                    Label      raceFee    = (Label)e.Row.FindControl("RaceFeeLabel");
                    Label      rentalFee  = (Label)e.Row.FindControl("RentalFeeLabel");
                    refund.Visible     = false;
                    raceFee.Visible    = false;
                    rentalFee.Visible  = false;
                    editButton.Visible = false;
                }
            }

            #region RowDataBound Edit
            if (!IsPostBack)
            {
                GridView1.Visible = false;
            }
            if ((e.Row.RowState & DataControlRowState.Edit) > 0)
            {
                var classes = controller.CarClasses_List(raceData.RaceID);

                DropDownList carClassesDropDown = (DropDownList)e.Row.FindControl("CarClassesDropDown");
                carClassesDropDown.DataSource = classes;
                if (raceData.CarID != null)
                {
                    carClassesDropDown.SelectedValue = raceData.CarClassID.ToString();
                }
                else
                {
                    string select = "Select a car class";
                    carClassesDropDown.Items.Insert(0, select);
                }
                try
                {
                    carClassesDropDown.DataBind();
                }
                catch (Exception ex)
                {
                    string output = string.Empty;
                    foreach (var singleClass in classes)
                    {
                        output = output + singleClass.CarClassName;
                    }

                    MessageUserControl1.ShowInfo(ex.Message,
                                                 ($"Currently Registered vehicle - '{raceData.CarClassName}' does not meet the class requirements of this race - '{output}'"));
                }

                if (raceData.CarID != null)
                {
                    List <CarViewModel> cars        = new List <CarViewModel>();
                    DropDownList        carDropDown = (DropDownList)e.Row.FindControl("CarDropDown");
                    cars = controller.Cars_List(int.Parse(carClassesDropDown.SelectedValue), raceData.RaceID, (int)raceData.CarID);
                    carDropDown.DataSource = cars;
                    if (raceData.CarID != null)
                    {
                        carDropDown.SelectedValue = raceData.CarID.ToString();
                    }
                    carDropDown.DataBind();
                }

                TextBox refundReason = (TextBox)e.Row.FindControl("RefundTextBox") as TextBox;
                if (refundReason.Text.Trim().Length > 0)
                {
                    refundReason.Visible = true;
                }
                Close_Results();
            }
            #endregion
        }