private void RefreshLeasedVehicles() { var parameters = new Dictionary <DictionaryParameter, string>(); if (ddlOwningCountry.SelectedValue != ParameterDataAccess.EmptyItem.Value) { parameters[DictionaryParameter.OwningCountry] = ddlOwningCountry.SelectedValue; } var rentingCountry = ddlRentingCountry.SelectedValue; var models = new List <string>(); var selectedModels = (from ListItem v in lbModels.Items where v.Selected select v).ToList(); if (selectedModels.Any() && selectedModels.Count() < lbModels.Items.Count) { models.AddRange((from ListItem v in lbModels.Items where v.Selected select v.Value).ToArray()); } using (var dataAccess = new SubleaseDataAccess(parameters)) { var leasedVehicles = dataAccess.GetSubleasedVehicles(rentingCountry, models); agSubleasedVehicles.GridData = leasedVehicles; } upnlGrid.Update(); }
protected void ClearAllSubleasedVehicles(object sender, EventArgs e) { using (var dataAccess = new SubleaseDataAccess(null)) { dataAccess.TruncateSubleasesTable(); } RefreshLeasedVehicles(); }
private void FillVehicleModels() { lbModels.Items.Clear(); using (var dataAccess = new SubleaseDataAccess(null)) { var models = dataAccess.GetSubleasedModels(); lbModels.Items.AddRange(models.ToArray()); } }
protected void UpdateVehicles(object sender, EventArgs e) { using (var dataAccess = new SubleaseDataAccess(null)) { var newSubleases = rbAddVehicles.Checked; var rentingCountry = ddlEditRentingCountry.SelectedValue; var startDate = DateTime.Parse(tbStartDate.Text); dataAccess.AddOrRemoveSubleasedVehicles(VehicleIdsToUpdate, newSubleases, rentingCountry, startDate); } RefreshLeasedVehicles(); }
protected void ParseVins(object sendere, EventArgs e) { var vinsEntered = new List <string>(); if (tbVinInput.Text.Contains(',')) { vinsEntered.AddRange(tbVinInput.Text.Split(',').Select(s => s.Trim()).ToList()); } else { vinsEntered.Add(tbVinInput.Text.Trim()); } using (var dataAccess = new SubleaseDataAccess(null)) { var newSubleases = rbAddVehicles.Checked; var vehicleIds = dataAccess.GetVehiclesFromVins(vinsEntered, newSubleases); VehicleIdsToUpdate = vehicleIds; } tbVinResults.Text = string.Format(hfVinResult.Value, VehicleIdsToUpdate.Count, vinsEntered.Count); mpeEditVehicles.Show(); btnApplyChangesToVehicles.Enabled = true; }