Beispiel #1
0
        private void saveButton_Click(object sender, EventArgs e)
        {            
            if(Valid())
            { 
                TripBl tripBl = new TripBl();

                try
                {
                    tripBl.Save(Id, DateTime.Parse(startDateDateTimePicker.Text + " " + startTimeDateTimePicker.Text), DateTime.Parse(endDateDateTimePicker.Text + " " + endTimeDateTimePicker.Text), int.Parse(vehicleComboBox.SelectedValue.ToString()), int.Parse(driverComboBox.SelectedValue.ToString()), RefillBl.GetPrevious(int.Parse(vehicleComboBox.SelectedValue.ToString())).Id, decimal.Parse(mileageStartTextBox.Text), decimal.Parse(mileageEndTextBox.Text), tripDetailsRichTextBox.Text, expenseAccountTextBox.Text);

                    startDateDateTimePicker.Text = startTimeDateTimePicker.Text = endDateDateTimePicker.Text = endTimeDateTimePicker.Text = DateTime.Now.ToString();
                    mileageStartTextBox.Text = mileageEndTextBox.Text = tripDetailsRichTextBox.Text = expenseAccountTextBox.Text = "";
                    Id = 0;
                }
                catch 
                {
                    MessageBox.Show("Trip not saved, make sure you add a fuel refill for this vehicle. ");
                }
                RefreshGrid();
                NewDriverCompobox();
                NewVehicleCompobox();
            }
        }
Beispiel #2
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (dataGridView.SelectedCells.Count > 0)
            {
                int selectedrowindex = dataGridView.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = dataGridView.Rows[selectedrowindex];

                Id = int.Parse(Convert.ToString(selectedRow.Cells["Id"].Value));

                if (MessageBox.Show(String.Format("Are you sure to delete a trip on {0}?", Convert.ToString(selectedRow.Cells["DateStart"].Value)), "Deleting...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    TripBl tripBl = new TripBl();
                    tripBl.Delete(Id);
                    Id = 0;

                    RefreshGrid();
                    NewDriverCompobox();
                }
            }
        }