Exemplo n.º 1
0
        private void NewVehicleCompobox()
        {
            vehicleComboBox.ValueMember   = "Id";
            vehicleComboBox.DisplayMember = "FullName";
            vehicleComboBox.DataSource    = VehicleData.GetList();

            if (vehicleComboBox.Items.Count > 0)
            {
                vehicleComboBox.SelectedIndex = 0;
            }

            mileageStartTextBox.Text = TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())) != null?TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())).MileageEnd.ToString() : "";
        }
Exemplo n.º 2
0
        public bool Valid()
        {
            if (String.IsNullOrEmpty(mileageStartTextBox.Text) ||
                String.IsNullOrWhiteSpace(mileageStartTextBox.Text) ||
                !Utility.IsNumber(mileageStartTextBox.Text)
                )
            {
                MessageBox.Show("Invalid value for mileage start");
                mileageStartTextBox.Focus();
                return(false);
            }

            if (TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())) != null && TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString()), Id).MileageEnd > decimal.Parse(mileageStartTextBox.Text))
            {
                MessageBox.Show("This vehicle is already above the mileage start given.");
                mileageStartTextBox.Focus();
                return(false);
            }

            if (String.IsNullOrEmpty(mileageEndTextBox.Text) ||
                String.IsNullOrWhiteSpace(mileageEndTextBox.Text) ||
                !Utility.IsNumber(mileageEndTextBox.Text)
                )
            {
                MessageBox.Show("Invalid value for mileage end");
                mileageEndTextBox.Focus();
                return(false);
            }

            if (Decimal.Parse(mileageEndTextBox.Text) < Decimal.Parse(mileageStartTextBox.Text))
            {
                MessageBox.Show("Mileage end can not be less than mileage start");
                mileageEndTextBox.Focus();
                return(false);
            }

            if (String.IsNullOrEmpty(tripDetailsRichTextBox.Text) ||
                String.IsNullOrWhiteSpace(tripDetailsRichTextBox.Text)
                )
            {
                MessageBox.Show("Invalid value for trip details");
                tripDetailsRichTextBox.Focus();
                return(false);
            }

            if (TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString()), Id) != null && DateTime.Parse(startDateDateTimePicker.Text + " " + startTimeDateTimePicker.Text) <= TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString()), Id).DateTimeEnd)
            {
                MessageBox.Show("Start date and time can not be before end of the previous trip for this vehicle");
                startDateDateTimePicker.Focus();
                return(false);
            }

            if (DateTime.Parse(startDateDateTimePicker.Text + " " + startTimeDateTimePicker.Text) >= DateTime.Parse(endDateDateTimePicker.Text + " " + endTimeDateTimePicker.Text))
            {
                MessageBox.Show("End date and time can not be before start date and time");
                endDateDateTimePicker.Focus();
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
 private void vehicleComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     mileageStartTextBox.Text = TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())) != null?TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())).MileageEnd.ToString() : "";
 }
Exemplo n.º 4
0
        public bool  Valid()
        {
            if (String.IsNullOrEmpty(mileageTextBox.Text) ||
                String.IsNullOrWhiteSpace(mileageTextBox.Text) ||
                !Utility.IsNumber(mileageTextBox.Text)
                )
            {
                MessageBox.Show("Invalid value for mileage");
                mileageTextBox.Focus();
                return(false);
            }

            if (Id == 0 && TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())) != null && TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())).MileageEnd > decimal.Parse(mileageTextBox.Text))
            {
                MessageBox.Show("This vehicle is already above the mileage given.");
                mileageTextBox.Focus();
                return(false);
            }

            if (Id > 0 && RefillBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString()), Id) != null && RefillBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString()), Id).Mileage > decimal.Parse(mileageTextBox.Text))
            {
                MessageBox.Show("This vehicle was already above the mileage given.");
                mileageTextBox.Focus();
                return(false);
            }

            if (String.IsNullOrEmpty(litreageTextBox.Text) ||
                String.IsNullOrWhiteSpace(litreageTextBox.Text) ||
                !Utility.IsNumber(litreageTextBox.Text)
                )
            {
                MessageBox.Show("Invalid value for litreage");
                litreageTextBox.Focus();
                return(false);
            }

            if (String.IsNullOrEmpty(amountTextBox.Text) ||
                String.IsNullOrWhiteSpace(amountTextBox.Text) ||
                !Utility.IsNumber(amountTextBox.Text)
                )
            {
                MessageBox.Show("Invalid value for amount");
                amountTextBox.Focus();
                return(false);
            }

            if (RefillBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString()), Id) != null && DateTime.Parse(dateTimePicker.Text) < RefillBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString()), Id).DateAndTime)
            {
                MessageBox.Show("Date can not be before the previous refill for this vehicle");
                dateTimePicker.Focus();
                return(false);
            }

            if (TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())) != null && DateTime.Parse(dateTimePicker.Text).Date < TripBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())).DateTimeEnd.Date)
            {
                MessageBox.Show("Date can not be before the previous last trip for this vehicle");
                dateTimePicker.Focus();
                return(false);
            }



            return(true);
        }