예제 #1
0
 private static Response ClearTrips(dynamic parameters)
 {
     TripBl.TruncateTrips();
     return(new Response {
         StatusCode = HttpStatusCode.NoContent
     });
 }
        public void TestSingleTripStartOrStopQueryAfterUpdateMessage()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 432
            });
            var totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(36, 121),
                                                                                           new GeoPoint(38, 123)));

            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(0));
            totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(38, 123),
                                                                                           new GeoPoint(40, 125)));
            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(0));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(0));
        }
        public void TestStartsAndStopsInGeoRectStartOrStopQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 38,
                Longitude = 123,
                TripId    = 432
            });
            var totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(36, 121),
                                                                                           new GeoPoint(39, 124)));

            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(25));
        }
        public void TestSingleTripPointInTimeQueryAfterUpdateMessage()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 432
            });
            var totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673020);

            Assert.That(totalTrips, Is.EqualTo(0));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673030);
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673040);
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673070);
            Assert.That(totalTrips, Is.EqualTo(1));
        }
        public void TestSingleTripThroughGeoRectQueryAfterUpdateMessage()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 432
            });
            var totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(36, 121), new GeoPoint(38, 123)));

            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(38, 123), new GeoPoint(40, 125)));
            Assert.That(totalTrips, Is.EqualTo(1));
        }
예제 #6
0
        public static List <TripData> GetList()
        {
            List <TripData> items = new List <TripData>();

            foreach (var item in TripBl.GetList())
            {
                TripData tripData = new TripData();

                tripData.Id             = item.Id;
                tripData.DateStart      = item.DateTimeStart.ToString("dddd dd MMM yyyy");
                tripData.TimeStart      = item.DateTimeStart.ToString("hh:mm tt");
                tripData.DateEnd        = item.DateTimeEnd.ToString("dddd dd MMM yyyy");
                tripData.TimeEnd        = item.DateTimeEnd.ToString("hh:mm tt");
                tripData.DriverId       = item.DriverId;
                tripData.DriverName     = new DriverBl().GetById(item.DriverId).FullName;
                tripData.VehicleId      = item.VehicleId;
                tripData.VehicleName    = string.Format("{0}({1})", new VehicleBl().GetById(item.VehicleId).Name, new VehicleBl().GetById(item.VehicleId).RegistrationNumber);
                tripData.RefillDate     = new RefillBl().GetById(item.RefillId).DateAndTime.ToString("dddd dd MMM yyyy");
                tripData.MileageStart   = item.MileageStart;
                tripData.MileageEnd     = item.MileageEnd;
                tripData.TripDetails    = item.TripDetails;
                tripData.ExpenseAccount = item.ExpenseAccount;

                items.Add(tripData);
            }

            return(items);
        }
예제 #7
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();
                }
            }
        }
예제 #8
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);
        }
        public void TestMultipleTripsStartOrStopQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 110,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 433
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 50,
                Latitude  = 50,
                Longitude = 130,
                TripId    = 433
            });
            var totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(29, 109),
                                                                                           new GeoPoint(31, 111)));

            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(25));
            totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(49, 129),
                                                                                           new GeoPoint(51, 131)));
            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(50));
            totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(39, 119),
                                                                                           new GeoPoint(41, 121)));
            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(2));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(75));
        }
예제 #10
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() : "";
        }
예제 #11
0
        private string GetTotalTripsThroughGeoRectangleResponseString()
        {
            var geoRectangle = GetGeoRectangle();

            return
                (JsonConvert.SerializeObject(
                     new
            {
                queryType = QueryType.ThroughGeoRect,
                geoRectangle,
                totalTrips = TripBl.GetTotalTripsThroughGeoRectangle(geoRectangle)
            }, SerializerSettings));
        }
예제 #12
0
        private string GetTotalTripsOccuringAtTimeResponseString()
        {
            var epoch = GetEpoch();

            return
                (JsonConvert.SerializeObject(
                     new
            {
                queryType = QueryType.PointInTime,
                epoch,
                numberOfTrips = TripBl.GetTotalTripsOccuringAtTime(epoch)
            }, SerializerSettings));
        }
        public void TestInsertBeginMessage()
        {
            var tripMessage = InsertBeginMessage();
            var trip        = TripBl.GetTrip(tripMessage.TripId);

            Assert.That(trip, Is.Not.Null);
            Assert.That(trip.BeginEpoch, Is.EqualTo(tripMessage.Epoch));
            Assert.That(trip.EndEpoch, Is.Null);
            Assert.That(trip.Fare, Is.Null);
            Assert.That(trip.Id, Is.EqualTo(tripMessage.TripId));
            Assert.That(trip.LastLatitude, Is.EqualTo(tripMessage.Latitude.Value));
            Assert.That(trip.LastLongitude, Is.EqualTo(tripMessage.Longitude.Value));
            Assert.That(trip.LastMessageEpoch, Is.EqualTo(tripMessage.Epoch));
        }
예제 #14
0
        private string GetTotalTripsAndFaresThatStartOrStopInGeoRectangle()
        {
            var geoRectangle       = GetGeoRectangle();
            var totalTripsAndFares = TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(geoRectangle);

            return
                (JsonConvert.SerializeObject(
                     new
            {
                queryType = QueryType.StartStopInGeoRect,
                geoRectangle,
                totalTrips = (int)totalTripsAndFares.TotalTrips,
                totalFares = (decimal)totalTripsAndFares.TotalFares
            }, SerializerSettings));
        }
        public void TestTripOnCornerThroughGeoRectQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 120,
                TripId    = 432
            });
            var totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(30, 120), new GeoPoint(40, 130)));

            Assert.That(totalTrips, Is.EqualTo(1));
        }
        public void TestMultipleTripsThroughGeoRectQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 110,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 433
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 50,
                Latitude  = 50,
                Longitude = 130,
                TripId    = 433
            });
            var totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(29, 109), new GeoPoint(31, 111)));

            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(49, 129), new GeoPoint(51, 131)));
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(39, 119), new GeoPoint(41, 121)));
            Assert.That(totalTrips, Is.EqualTo(2));
        }
        public void TestTripOnCornerStartOrStopQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 120,
                TripId    = 432
            });
            var totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(30, 120),
                                                                                           new GeoPoint(40, 130)));

            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(0));
        }
예제 #18
0
        private static Response GetTrip(dynamic parameters)
        {
            Response response;
            var      trip = TripBl.GetTripWithMessages((int)parameters.tripId);

            if (null == trip)
            {
                response            = string.Empty;
                response.StatusCode = HttpStatusCode.NotFound;
            }
            else
            {
                response             = JsonConvert.SerializeObject(trip);
                response.ContentType = "application/json";
                response.StatusCode  = HttpStatusCode.OK;
            }
            return(response);
        }
예제 #19
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();
                }
            }
        }
예제 #20
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();
            }
        }
        public void TestEntireTripContainedInGeoRectThroughGeoRectQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 38,
                Longitude = 123,
                TripId    = 432
            });
            var totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(36, 121), new GeoPoint(39, 124)));

            Assert.That(totalTrips, Is.EqualTo(1));
        }
예제 #22
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);
        }
 private static void GetTripQueryWithInvalidEpoch()
 {
     TripBl.GetTotalTripsOccuringAtTime(0);
 }
        public void TestMultipleTripPointInTimeQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 110,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Begin,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 433
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 433
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673080,
                Event     = TripEvent.End,
                Fare      = 50,
                Latitude  = 50,
                Longitude = 130,
                TripId    = 433
            });
            var totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673020);

            Assert.That(totalTrips, Is.EqualTo(0));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673030);
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673040);
            Assert.That(totalTrips, Is.EqualTo(2));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673070);
            Assert.That(totalTrips, Is.EqualTo(2));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673080);
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673090);
            Assert.That(totalTrips, Is.EqualTo(0));
        }
 public void CleanUp()
 {
     TripBl.TruncateTrips();
 }
예제 #26
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() : "";
 }
예제 #27
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);
        }
 private static void GetTripQueryWithInvalidGeoPointLatitude()
 {
     TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(-91, 0), new GeoPoint(37, 122)));
 }
 private static void GetTripQueryWithInvalidGeoPointLongitude()
 {
     TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(-37, 122), new GeoPoint(0, 181)));
 }
 private static void GetTripQueryWithInvalidGeoRectangleLongitudes()
 {
     TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(50, 122), new GeoPoint(60, 100)));
 }