private void CompleteChaufferButton_Click(object sender, EventArgs e)
        {
            if (NotificationsLV.SelectedItems.Count > 0)
            {
                var notificationId = Int32.Parse(NotificationsLV.SelectedItems[0].Text);
                var notification   = _dbContext.Notifications.SingleOrDefault(
                    n => n.NotificationId == notificationId
                    );
                var request = _dbContext.RideRequests.SingleOrDefault(
                    r => r.RideRequestId == notification.RideRequestId
                    );

                if (request.RideStatus != DataTypes.RideStatus.Complete)
                {
                    request.RideStatus = DataTypes.RideStatus.Complete;

                    // update db
                    _dbContext.SaveChanges();

                    // close window
                    var riderMainMenu = (RiderMainMenu)Tag;
                    riderMainMenu.Show();
                    Close();
                }
                else
                {
                    MessageBox.Show("Notification has already been completed");
                }
            }
            else
            {
                MessageBox.Show("Please select a notification in order to complete it");
            }
        }
Example #2
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            if (
                PickupTimeTB.Text == string.Empty ||
                LocationTB.Text == string.Empty ||
                DestinationTB.Text == string.Empty ||
                PaymentTypeCB.Text == string.Empty ||
                AmountTB.Text == string.Empty
                )
            {
                MessageBox.Show("Please Fill Out All Fields");
            }
            else
            {
                // ride requests also have payments
                var rideRequest = new RideRequest
                {
                    RiderId            = HomePage.CurrentUser.GetId(),
                    PickupAddress      = LocationTB.Text,
                    DestinationAddress = DestinationTB.Text,
                    DesiredPickupTime  = Convert.ToDateTime(PickupTimeTB.Text),
                    RideStatus         = RideStatus.Unfulfilled,
                    ChaufferId         = null
                };

                // set up payment.
                var payment = new Payment
                {
                    RideRequestId = rideRequest.RideRequestId,
                    PaymentType   = (PaymentType)Enum.Parse(typeof(PaymentType), PaymentTypeCB.Text),
                    Amount        = Decimal.Parse(AmountTB.Text),
                };

                // update database
                _dbContext.RideRequests.Add(rideRequest);
                _dbContext.Payments.Add(payment);
                _dbContext.SaveChanges();

                // close window
                var riderMainMenu = (RiderMainMenu)Tag;
                riderMainMenu.Show();
                Close();
            }
        }
Example #3
0
        private void ChuafferButton_Click(object sender, EventArgs e)
        {
            if (CurrentRequestsLV.SelectedItems.Count > 0)
            {
                var selectedRequestId = Int32.Parse(CurrentRequestsLV.SelectedItems[0].Text);

                Request = _dbContext.RideRequests.SingleOrDefault(
                    rr => rr.RideRequestId == selectedRequestId
                    );

                Payment = _dbContext.Payments.SingleOrDefault(
                    p => p.RideRequestId == Request.RideRequestId
                    );

                // starting chauffer creates a notification
                var notification = new Notification
                {
                    DriverFirstName = HomePage.CurrentUser.FirstName,
                    VehicleType     = HomePage.CurrentUser.GetVehicleType(),
                    LicensePlateNum = HomePage.CurrentUser.GetLicensePlateNumber(),
                    ETA             = Convert.ToDateTime(ETADTP.Text),
                    ChaufferId      = HomePage.CurrentUser.GetId(),
                    RiderId         = Request.RiderId,
                    RideRequestId   = Request.RideRequestId
                };

                // puts a chuafferId to the ride request
                Request.ChaufferId = HomePage.CurrentUser.GetId();
                Request.RideStatus = DataTypes.RideStatus.InProgress;


                // return to previous screen and update DB
                _dbContext.Notifications.Add(notification);
                _dbContext.SaveChanges();

                var chaufferMainMenu = (ChaufferMainMenu)Tag;
                chaufferMainMenu.Show();
                Close();
            }
            else
            {
                MessageBox.Show("Please select a request in order to chauffer them");
            }
        }
Example #4
0
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            // create the user, if they have already been created notify that they are in the system!
            bool success = false;

            if (ChaufferYesNoCB.Checked)
            {
                // The User is registering as a chauffer
                if (
                    FirstNameTB.Text == string.Empty ||
                    LastNameTB.Text == string.Empty ||
                    UserNameTB.Text == string.Empty ||
                    PasswordTB.Text == string.Empty ||
                    VehicleTypeCB.SelectedIndex == -1 ||
                    LicensePlateNumberTB.Text == string.Empty
                    )
                {
                    MessageBox.Show("Please Fill Out All Fields");
                }
                else
                {
                    var chauffer = new Chauffer
                    {
                        FirstName          = FirstNameTB.Text,
                        LastName           = LastNameTB.Text,
                        UserName           = UserNameTB.Text,
                        Password           = PasswordTB.Text,
                        VehicleType        = (VehicleType)Enum.Parse(typeof(VehicleType), VehicleTypeCB.Text),
                        LicensePlateNumber = LicensePlateNumberTB.Text
                    };
                    _dbContext.Chauffers.Add(chauffer);
                    _dbContext.SaveChanges();
                    success = true;
                }
            }
            else
            {
                // The user is registering as a rider
                if (
                    FirstNameTB.Text == string.Empty ||
                    LastNameTB.Text == string.Empty ||
                    UserNameTB.Text == string.Empty ||
                    PasswordTB.Text == string.Empty
                    )
                {
                    MessageBox.Show("Please Fill Out All Fields");
                }
                else
                {
                    var rider = new Rider
                    {
                        FirstName = FirstNameTB.Text,
                        LastName  = LastNameTB.Text,
                        UserName  = UserNameTB.Text,
                        Password  = PasswordTB.Text
                    };
                    _dbContext.Riders.Add(rider);
                    _dbContext.SaveChanges();
                    success = true;
                }
            }

            // if successful update the DB and close
            if (success == true)
            {
                var homePage = (HomePage)Tag;
                homePage.Show();
                Close();
            }
        }