private string createDateKey(VehicleAdminObject currVehicle, PropertyId p) { string monthAndYearKey = string.Empty; string dateString = currVehicle.GetValue(p); DateTime d = DateTime.Parse(dateString); monthAndYearKey = d.Month + "-" + d.Year; return monthAndYearKey; }
public void LoadPanel(IAdminObject item) { _vehicle = item as VehicleAdminObject; if (_vehicle == null) return; VehicleListView.LoadPanel(_vehicle); }
public VehicleTileControl(VehicleAdminObject vehicle) { InitializeComponent(); _vehicle = vehicle; _defaultBrush = this.BorderBrush; Initialize(); this.ToolTip = String.Format("{0} {1} {2} : {3}", _vehicle.GetValue(PropertyId.Year), _vehicle.GetValue(PropertyId.Make), _vehicle.GetValue(PropertyId.Model), _vehicle.GetValue(PropertyId.Trim)); }
private double CalculateTasksCost(VehicleAdminObject vehicleAdminObject) { double totalCost = 0; foreach (VehicleTask vehicleTask in vehicleAdminObject.VehicleTasks) { double cost = 0; if (Utilities.StringToDouble(vehicleTask.Cost, out cost)) { totalCost += cost; } } return totalCost; }
public PrintCar(VehicleAdminObject vehicle, Object sender, EventArgs e) { currVehicle = vehicle; PrintDocument brochure = new PrintDocument(); try { brochure.PrintPage += new PrintPageEventHandler(this.printBrochure); } catch (Exception ex) { MessageBox.Show(ex.Message); } PrintDialog printDialog = new PrintDialog(); printDialog.Document = brochure; if (printDialog.ShowDialog() == DialogResult.OK) { brochure.Print(); } }
public PrintAppraisalForm(VehicleAdminObject vehicle, Object sender, EventArgs e) { currVehicle = vehicle; PrintDocument invoice = new PrintDocument(); try { invoice.PrintPage += new PrintPageEventHandler(this.printAppraisalForm); } catch (Exception ex) { MessageBox.Show("PrintAppraisal: " + ex.Message); } PrintDialog printDialog = new PrintDialog(); printDialog.Document = invoice; if (printDialog.ShowDialog() == DialogResult.OK) { invoice.Print(); } }
public void LoadPanel(IAdminObject item) { _vehicle = item as VehicleAdminObject; ClearFormState(); LoadAllChildren(PurchaseInfoGrid, item); addtionalContentControl.ListChanged += addtionalContentControl_ListChanged; string foundVendor = _vehicle.GetValue(PropertyId.Vendor); WellKnownVendors vehicleVendor = WellKnownVendors.Adesa; bool foundVehicleVendor = false; if (!string.IsNullOrEmpty(foundVendor)) { foundVehicleVendor = true; vehicleVendor = (WellKnownVendors)Enum.Parse(typeof(WellKnownVendors), foundVendor, true); } int foundIndex = -1; cmbVendor.Items.Add(""); foreach (WellKnownVendors vendor in (WellKnownVendors[])Enum.GetValues(typeof(WellKnownVendors))) { cmbVendor.Items.Add(vendor.ToString()); if (foundVehicleVendor && vendor == vehicleVendor) { foundIndex = cmbVendor.Items.Count - 1; } } if (foundIndex != -1) { cmbVendor.SelectedIndex = foundIndex; } CalculateTasksCost(); }
private void loadURL(VehicleAdminObject vehicle, string url) { _vehicle = vehicle; Regex validURL = new Regex(@"\A(https?|ftp|file)://.+\z"); if (validURL.IsMatch(url)) { imagePaths = new List<string[]>(); Regex hostPattern = new Regex(@"[a-z][a-z0-9+\-.]*://([a-z0-9\-._~%]+|\[[a-z0-9\-._~%!$&'()*+,;=:]+\])", RegexOptions.IgnoreCase); Match host = hostPattern.Match(url); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); StreamReader inStream = new StreamReader(res.GetResponseStream()); string page = inStream.ReadToEnd(); inStream.Close(); res.Close(); //Exterior Color string exteriorColor = "Exterior Colour:\n</strong>\n<span class=\"value\">"; int startIndex = page.IndexOf(exteriorColor, System.StringComparison.Ordinal); int length = page.IndexOf("</", startIndex + exteriorColor.Length, System.StringComparison.Ordinal) - startIndex - exteriorColor.Length; string foundExteriorColor = page.Substring(startIndex + exteriorColor.Length, length); dataMap.Add(PropertyId.ExtColor, foundExteriorColor.Trim()); string bodyStyle = "bodyStyle: '"; startIndex = page.IndexOf(bodyStyle, System.StringComparison.Ordinal); length = page.IndexOf("'", startIndex + bodyStyle.Length, System.StringComparison.Ordinal) - startIndex - bodyStyle.Length; string foundBodyStyle = page.Substring(startIndex + bodyStyle.Length, length); dataMap.Add(PropertyId.Bodystyle, foundBodyStyle.Trim()); string Year = "year: '"; startIndex = page.IndexOf(Year, System.StringComparison.Ordinal); length = page.IndexOf("'", startIndex + Year.Length, System.StringComparison.Ordinal) - startIndex - Year.Length; string foundYear = page.Substring(startIndex + Year.Length, length); dataMap.Add(PropertyId.Year, foundYear.Trim()); string Make = "make: '"; startIndex = page.IndexOf(Make, System.StringComparison.Ordinal); length = page.IndexOf("'", startIndex + Make.Length, System.StringComparison.Ordinal) - startIndex - Make.Length; string foundMake = page.Substring(startIndex + Make.Length, length); dataMap.Add(PropertyId.Make, foundMake.Trim()); string Model = "model: '"; startIndex = page.IndexOf(Model, System.StringComparison.Ordinal); length = page.IndexOf("'", startIndex + Model.Length, System.StringComparison.Ordinal) - startIndex - Model.Length; string foundModel = page.Substring(startIndex + Model.Length, length); dataMap.Add(PropertyId.Model, foundModel.Trim()); string Transmission = "Transmission:\n</strong>\n<span class=\"value\">"; startIndex = page.IndexOf(Transmission, System.StringComparison.Ordinal); length = page.IndexOf("<", startIndex + Transmission.Length, System.StringComparison.Ordinal) - startIndex - Transmission.Length; string foundTransmission = page.Substring(startIndex + Transmission.Length, length); dataMap.Add(PropertyId.Transmission, foundTransmission.Trim()); string Engine = "Engine:\n</strong>\n<span class=\"value\">"; startIndex = page.IndexOf(Engine, System.StringComparison.Ordinal); length = page.IndexOf("<", startIndex + Engine.Length, System.StringComparison.Ordinal) - startIndex - Engine.Length; string foundEngine = page.Substring(startIndex + Engine.Length, length); dataMap.Add(PropertyId.Engine, foundEngine.Trim()); string StockNumber = "Stock #:\n</strong>\n<span class=\"value\">"; startIndex = page.IndexOf(StockNumber, System.StringComparison.Ordinal); length = page.IndexOf("<", startIndex + StockNumber.Length, System.StringComparison.Ordinal) - startIndex - StockNumber.Length; string foundStockNumber = page.Substring(startIndex + StockNumber.Length, length); dataMap.Add(PropertyId.StockNumber, foundStockNumber.Trim()); string Mileage = "Kilometres:\n</strong>\n<span class=\"value\">"; startIndex = page.IndexOf(Mileage, System.StringComparison.Ordinal); length = page.IndexOf(" km", startIndex + Mileage.Length, System.StringComparison.Ordinal) - startIndex - Mileage.Length; string foundMileage = page.Substring(startIndex + Mileage.Length, length); dataMap.Add(PropertyId.Mileage, foundMileage.Trim()); string Price = "<strong class=\"h1 price\">"; startIndex = page.IndexOf(Price, System.StringComparison.Ordinal); length = page.IndexOf("<", startIndex + Price.Length, System.StringComparison.Ordinal) - startIndex - Price.Length; string foundPrice = page.Substring(startIndex + Price.Length, length); dataMap.Add(PropertyId.ListPrice, foundPrice.Trim()); string Trim = "<h1> " + foundYear + " " + foundMake + " " + foundModel; startIndex = page.IndexOf(Trim, System.StringComparison.Ordinal); length = page.IndexOf("<", startIndex + Trim.Length, System.StringComparison.Ordinal) - startIndex - Trim.Length; string foundTrim = page.Substring(startIndex + Trim.Length, length); dataMap.Add(PropertyId.Trim, foundTrim.Trim()); // Load Images string linkHeader = "<a href=\""; startIndex = 0; int foundIndex = page.IndexOf(linkHeader, startIndex, System.StringComparison.Ordinal); while (foundIndex != -1) { startIndex = foundIndex; int stringLength = page.IndexOf("\"", startIndex + linkHeader.Length, System.StringComparison.Ordinal) - foundIndex - linkHeader.Length; string foundLink = page.Substring(foundIndex + linkHeader.Length, stringLength); if (foundLink.EndsWith(".jpg")) { if (foundLink.StartsWith("//")) { foundLink = foundLink.Substring(2); foundLink = "http://" + foundLink; } WebClient downloadClient = new WebClient(); string tempOutputFile = Resources.Settings.TempFolder + "\\Image" + DateTime.Now.ToFileTimeUtc().ToString() + ".jpg"; downloadClient.DownloadFile(foundLink, tempOutputFile); string outputFile = Settings.MoveToItemImageFolder(vehicle, tempOutputFile); imagePaths.Add(new string[] { PropertyId.VehicleImage.ToString(), outputFile }); File.Delete(tempOutputFile); } foundIndex = page.IndexOf(linkHeader, startIndex + 1, System.StringComparison.Ordinal); } result = VehicleImportStatus.PASS; } }
public VehicleUrlImport(VehicleAdminObject vehicle,string url) { loadURL(vehicle, url); }
private void UpdateListHighlights(VehicleAdminObject vehicle) { if (vehicle == null) return; foreach (ListViewItem listViewItem in lstTasks.Items) { VehicleTask task = listViewItem.Content as VehicleTask; if (task == null) continue; if (vehicle.Id == task.TaskVehicleId) { listViewItem.Background = Brushes.DeepSkyBlue; } else { listViewItem.Background = Brushes.White; } } foreach (ListViewItem listViewItem in lstVehicles.LstSearchResults.Items) { VehicleAdminObject vehicleItem = listViewItem.Content as VehicleAdminObject; if (vehicleItem == null) continue; if (vehicleItem.Id == vehicle.Id) { listViewItem.Background = Brushes.DeepSkyBlue; } else { listViewItem.Background = Brushes.White; } } }
private void updatePurchasedVehicleList(VehicleAdminObject currVehicle, string monthAndYearPurchased) { if (purchasedVehicles.ContainsKey(monthAndYearPurchased)) { purchasedVehicles[monthAndYearPurchased].Add(currVehicle); } else { List<VehicleAdminObject> newList = new List<VehicleAdminObject> { currVehicle }; purchasedVehicles.Add(monthAndYearPurchased, newList); } return; }
private bool isSold(VehicleAdminObject v) { string s = v.GetValue(PropertyId.SaleDate); return (s == null || s == string.Empty) ? false : true; }
private bool isPurchased(VehicleAdminObject v) { string p = v.GetValue(PropertyId.PurchaseDate); return (p == null || p == string.Empty) ? false : true; }
private void cache_ItemUpdate(object sender, AdminItemCache.UpdateEventArgs e) { if (e.Type == AdminItemCache.UpdateType.ModifyItem) { ListViewItem listViewItem = (from ListViewItem item in LstSearchResults.Items let listContent = item.Content as VehicleAdminObject where listContent.ObjectId == e.ItemId select item).FirstOrDefault(); VehicleAdminObject cacheContent = cache.FirstOrDefault(vehicleAdminObject => vehicleAdminObject.ObjectId == e.ItemId); if (cacheContent != null) { VehicleCache tempCache = cacheContent.Cache as VehicleCache; cacheContent = new VehicleAdminObject(cacheContent.ObjectId); cacheContent.Cache = tempCache; if (cacheContent.GetValue(PropertyId.IsDeleted) == true.ToString()) { LstSearchResults.Items.Remove(listViewItem); return; } } if (listViewItem != null) { listViewItem.Content = null; listViewItem.Content = cacheContent; } } }
private void clearState() { _foundVehicle = null; lblVinSearchResults.Content = String.Empty; btnCheckIn.Visibility = Visibility.Collapsed; btnCheckOut.Visibility = Visibility.Collapsed; }
private void txtVinSearch_TextChanged(object sender, TextChangedEventArgs e) { if (txtVinSearch.Text.Length != 6) { clearState(); return; } if (CacheManager.AllVehicleCache == null) { MessageBox.Show("CacheManager.AllVehicleCache not yet loaded please wait and try again"); return; } foreach (VehicleAdminObject vehicleAdminObject in CacheManager.AllVehicleCache) { if (vehicleAdminObject.GetValue(PropertyId.VinNumber).ToLower().EndsWith(txtVinSearch.Text.ToLower())) { _foundVehicle = vehicleAdminObject; } } if (_foundVehicle == null) { clearState(); return; } lblVinSearchResults.Content = _foundVehicle.Year + " " + _foundVehicle.Make + " " + _foundVehicle.Model; string checkOutUser = _foundVehicle.GetValue(PropertyId.CheckOutBy); if (string.IsNullOrEmpty(checkOutUser)) { btnCheckOut.Visibility = Visibility.Visible; } else { btnCheckIn.Visibility = Visibility.Visible; } }
private void updateSoldVehicleList(VehicleAdminObject currVehicle, string monthAndYearSold) { if (soldVehicles.ContainsKey(monthAndYearSold)) { soldVehicles[monthAndYearSold].Add(currVehicle); } else { List<VehicleAdminObject> newList = new List<VehicleAdminObject> { currVehicle }; soldVehicles.Add(monthAndYearSold, newList); } return; }
public static void LoadVehicleInfoWindow(VehicleAdminObject vehicle) { LoadVehicleInfoWindow(vehicle, VehicleInfoWindow.VehicleInfoWindowTabs.Default); }
public static void LoadVehicleInfoWindow(VehicleAdminObject vehicle, VehicleInfoWindow.VehicleInfoWindowTabs startTab) { try { if (vehicle == null) { throw new NullReferenceException("Load vehicle info window requires non null vehicle"); } else { IAdminItemCache tempCache = vehicle.Cache; //THIS FORCES VEHICLE TO REFRESH //vehicle = new VehicleAdminObject(vehicle.ObjectId); vehicle.Cache = tempCache; VehicleInfoWindow window = new VehicleInfoWindow(vehicle, startTab); if (CacheManager.MainTabControl == null) { throw new NotImplementedException("MainTabControl == null"); } ClosableTab tabItem = new ClosableTab(); tabItem.BackGroundColor = LookAndFeel.VehicleTabColor; window.SetParentTabControl(tabItem); tabItem.Height = LookAndFeel.TabItemHeight; tabItem.Title = vehicle.Year + ": " + vehicle.Make + " " + vehicle.Model; tabItem.Content = window; CacheManager.MainTabControl.Items.Add(tabItem); tabItem.Focus(); //window.Show(); //CacheManager.ActiveUser.AddPage(window); } } catch (Exception ex) { MessageBox.Show("ERROR: Try to load LoadVehicleInfoWindow again\n" + ex.StackTrace); } }
public void LoadPanel(IAdminObject item) { _vehicle = null; TxtCustomerId.Text = ""; _vehicle = item as VehicleAdminObject; ClearFormState(); LoadAllChildren(SaleInfoGrid, item); LoadAllChildren(WarrantyGrid, item); LoadAllChildren(TradeInGrid, item); addtionalContentControl.ListChanged += addtionalContentControl_ListChanged; LoadComboBoxes(); if (!CacheManager.ActiveUser.Permissions.Contains(UserAdminObject.PermissionTypes.UpdateSaleTaxPercentage)) { txtSalesTaxPercentage.Visibility = Visibility.Hidden; } if (string.IsNullOrEmpty(txtSalesTaxPercentage.Text)) { txtSalesTaxPercentage.Text = Settings.HST.ToString(CultureInfo.InvariantCulture); } }
private void AddVehicleTile(VehicleAdminObject vehicle) { VehicleTileControl iconControl = new VehicleTileControl(vehicle); iconControl.MouseDoubleClick += iconControl_MouseDoubleClick; ActiveVehiclesWrapPanel.Children.Add(iconControl); }