예제 #1
0
        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();
        }
예제 #2
0
 protected void ClearAllSubleasedVehicles(object sender, EventArgs e)
 {
     using (var dataAccess = new SubleaseDataAccess(null))
     {
         dataAccess.TruncateSubleasesTable();
     }
     RefreshLeasedVehicles();
 }
예제 #3
0
 private void FillVehicleModels()
 {
     lbModels.Items.Clear();
     using (var dataAccess = new SubleaseDataAccess(null))
     {
         var models = dataAccess.GetSubleasedModels();
         lbModels.Items.AddRange(models.ToArray());
     }
 }
예제 #4
0
        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();
        }
예제 #5
0
        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;
        }