Example #1
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 {0}?", Convert.ToString(selectedRow.Cells["FullName"].Value)), "Deleting...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if(TripBl.DriverInUse(Id))
                    {
                        MessageBox.Show("Driver is in use, can't be deleted.");
                        return;
                    }

                    DriverBl driverBl = new DriverBl();
                    driverBl.Delete(Id);
                    Id = 0;

                    RefreshGrid();
                }
            }
        }
Example #2
0
        private void saveButton_Click(object sender, EventArgs e)
        {           
            if(Valid())
            {
                DriverBl driverBl = new DriverBl();

                driverBl.Save(Id, fullNameTextBox.Text);

                fullNameTextBox.Text = "";
                Id = 0;

                RefreshGrid();
            }
            
        }
Example #3
0
        public static List<MasterReport> GetList()
        {
            List<MasterReport> items = new List<MasterReport>();



            foreach(var item in TripBl.GetList())
            {
                MasterReport reportData = new MasterReport();
                Refill r = new RefillBl().GetById(item.RefillId);
                Vehicle v = new VehicleBl().GetById(item.VehicleId);
                Driver d = new DriverBl().GetById(item.DriverId);

                string closed = "";

                reportData.DateTimeStart = string.Format("{0}", item.DateTimeStart.ToString("dd/MM/yy,hh:mm tt"));
                reportData.DateTimeEnd = string.Format("{0}", item.DateTimeEnd.ToString("dd/MM/yy,hh:mm tt"));
                reportData.DriverName = d.FullName;
                reportData.DriverId = d.Id;
                reportData.VehicleName = string.Format("{0}({1})", v.Name, v.RegistrationNumber);
                reportData.VehicleId = v.Id;
                reportData.Refill = string.Format("Refill No: {5}\nDate: {0}\nAmount: ${1}\nLiterage: {2}L\nPerfo': {3}km/l\nStatus: {4}", r.DateAndTime.ToString("dd/MM/yy "), r.Amount, r.Litreage, (RefillBl.TotalMileage(r.Id)/(decimal)r.Litreage).ToString("N2"), closed = r.Closed ? "Closed" : "Open", r.Id);
                reportData.RefillId = r.Id;
                reportData.MileageStart = item.MileageStart;
                reportData.MileageEnd = item.MileageEnd;
                reportData.MileageTravelled = (item.MileageEnd - item.MileageStart);
                reportData.TripDetails = item.TripDetails;
                reportData.ExpenseAccount = item.ExpenseAccount;
                reportData.Cost = (reportData.MileageTravelled / RefillBl.TotalMileage(r.Id)) * r.Amount;
                    
                items.Add(reportData);

            }

            return items;
        }