//View the Selected Vehicle private void ViewSelected(object obj) { if (RequestProcessingList != null) { var vehicleModel = RequestProcessingList.FirstOrDefault(); var home = new HomeWindowVM(); var vehicleLocator = new VehicleLocatorVM(); var vehicleDetails = new VehicleDetail(); var window = new Window() { Content = vehicleDetails }; window.DataContext = vehicleLocator.VehicalDetailsViewModel; vehicleLocator.Vin = vehicleModel.Vin; vehicleLocator.VehicleId = vehicleModel.VehiclesID; vehicleLocator.CustomerID = vehicleModel.CustomerID; vehicleLocator.CreatedBy = vehicleModel.CreatedBy; vehicleLocator.SelectedItems = new ObservableCollection <object>() { vehicleLocator }; var list = new List <VehicleLocatorVM>() { vehicleLocator }; DelegateEventVehicle.SetValueListMethod(list); DelegateEventVehicle.SetValueMethodTabEnable(false); DelegateEventVehicle.SetValueMethodCmd("Edit"); window.Show(); } }
/// <summary> /// Function UpdatePortStorageDateOut to update the vehicle details to database /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public void UpdatePortStorageDateOutBatchProcess(object obj) { try { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); VehicleProp objVehicleProp = new VehicleProp(); foreach (var item in RequestProcessingList) { objVehicleProp.Vin = item.Vin; objVehicleProp.DateOut = item.DateOut; objVehicleProp.VehiclesID = item.VehiclesID; objVehicleProp.UpdatedBy = Application.Current.Properties["LoggedInUserName"].ToString(); string message = _serviceInstance.DateOutBatchProcess(objVehicleProp); if (!string.IsNullOrEmpty(message)) { var data = _serviceInstance.GetPortStorageDateOutProcessignDetails(objVehicleProp.Vin).Select(d => new VehicleModel { Vin = d.Vin, Name = d.Name, DateIn = d.DateIn, DateOut = d.DateOut, MakeModel = d.MakeModel, BayLocation = d.BayLocation, VehicleStatus = message, }); VehicleModel objVehicleModel = new VehicleModel(); objVehicleModel = data.FirstOrDefault(); RequestProcessingList.Add(objVehicleModel); } } } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Function Cancle to refresh the page state /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public void Cancle(object obj) { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { //empty the grid RequestProcessingList.Clear(); } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Function UpdatePortStorageDateOutProcessignDetails to get the vehicle details /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public void UpdateAndGetPortStorageDateOutProcessignDetails(object obj) { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { if (string.IsNullOrEmpty(Vin)) { MessageBox.Show(Resources.msgVINReq, Resources.msgTitleMessageBox); return; } // Cannot allow multiples. if (RequestProcessingList.Any(it => it.Vin.Contains(Vin))) { MessageBox.Show(Resources.msgVehicleListAlready, Resources.msgTitleMessageBoxVehicleList); ClearFiled(); return; } // If there are no vehicles matching VIN, alert, and end. List <VehicleProp> vehiclesMatchingVIN = CheckMultipleVecheleDetailByVIN(Vin.ToUpper()); if (vehiclesMatchingVIN.Any() == false) { MessageBox.Show(Resources.msgProcessingVINFound, Resources.msgTitleMessageBoxVehicleNotFound); return; } // Create LINQ statement grabbing first two vehicles matching VIN that do not have date out. string shortVin = Vin.Substring(0, 8); IEnumerable <VehicleProp> firstTwoVehiclesWithoutDateOut = vehiclesMatchingVIN.Where(x => x.DateOut == null).Take(2); // If there are no vehicles that have no date out, alert with information on vehicle that does, and end. if (firstTwoVehiclesWithoutDateOut.Any() == false) { VehicleProp vehicleFound = GetVecheleDetailByVIN(shortVin); MessageBox.Show($"{Resources.msgDateoutProcess + vehicleFound.Name} IN: {vehicleFound.DateIn} REQ: {vehicleFound.DateRequested} OUT: {vehicleFound.DateOut}", "Vehicle Not Found"); ClearFiled(); return; } // If there are multiple vehicles matching VIN with no date out, alert, and end. if (firstTwoVehiclesWithoutDateOut.Count() == 2) { MessageBox.Show(Resources.msgMultipleVINProcessing, Resources.msgTitleMessageBoxMultipleVIN); return; } // Update vehicle details to make date out now. var updateVehicle = new VehicleProp { VehiclesID = firstTwoVehiclesWithoutDateOut.First().VehiclesID, Vin = Vin.Substring(0, 8), DateOut = DtDateOut, Note = Note, }; int value = _serviceInstance.UpdatePortStorageDateOutProcessignDetails(updateVehicle); // If update was successful, add vehicle to list for display on grid. if (value > 0) { VehicleProp foundVehicle = _serviceInstance.GetPortStorageDateOutProcessignDetails(shortVin).First(); VehicleModel vehicleModel = new VehicleModel { Vin = foundVehicle.Vin, Name = foundVehicle.Name, DateIn = foundVehicle.DateIn, DateOut = DtDateOut, MakeModel = foundVehicle.MakeModel, VehiclesID = foundVehicle.VehiclesID, BayLocation = foundVehicle.BayLocation, VehicleStatus = foundVehicle.VehicleStatus, }; RequestProcessingList.Add(vehicleModel); } ClearFiled(); Scrolled = "NOTSCROLLED"; } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
//Clear the finished Records from the Grid private void ClearFinished(object obj) { RequestProcessingList.Clear(); //VehicleStatus }