public bool UpdateVehicleTask(VehicleTask mFaceTask) { var filter = Builders <VehicleTask> .Filter.Eq(s => s.Id, mFaceTask.Id); mVehicleTaskCollection.ReplaceOne(filter, mFaceTask); return(true); }
private void simpleButtonAdd_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textEdit1.Text)) { mTaskPath = textEdit1.Text; VehicleTask vehicleTask = new VehicleTask(); vehicleTask.CreateTime = new BsonDateTime(DateTime.Now); vehicleTask.TaskId = DateTime.Now.ToString("yyyyMMddHHmmssfff"); vehicleTask.TaskPath = mTaskPath; vehicleTask.TaskState = "0"; vehicleTask.TaskCount = "0"; bool bResult = VehicleMongoDAL.GetInstance().AddVehicleTask(vehicleTask); if (bResult) { XtraMessageBox.Show("添加成功!"); loadTaskData(); } } else { XtraMessageBox.Show("先选择路径!"); } }
public bool AddVehicleTask(VehicleTask mFaceTask) { mVehicleTaskCollection.InsertOne(mFaceTask); return(true); }
private void txtWarrantyCost_TextChanged(object sender, TextChangedEventArgs e) { CalculateTotal_TextChanged(sender, e); double warranty = 0; if (Utilities.StringToDouble(txtWarrantyCost.Text, out warranty) && !warranty.Equals(0)) { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.PURCHASEWARRANTYTASK)) { return; } } VehicleTask purchaseWarrantyTask = new VehicleTask(); purchaseWarrantyTask.Id = Strings.PURCHASEWARRANTYTASK; purchaseWarrantyTask.TaskVehicleId = _vehicle.Id; purchaseWarrantyTask.CreatedDate = DateTime.Today.Date.ToString("d"); purchaseWarrantyTask.Status = VehicleTask.StatusTypes.NotStarted.ToString(); purchaseWarrantyTask.AssignedTo = "Mathew Toma"; purchaseWarrantyTask.Category = VehicleTask.TaskCategoryTypes.Detail.ToString(); purchaseWarrantyTask.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(purchaseWarrantyTask); } else { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.PURCHASEWARRANTYTASK)) { if (vehicleTask.Status != VehicleTask.StatusTypes.Completed.ToString()) _vehicle.VehicleTasks.Remove(vehicleTask); break; } } } _vehicle.SetMultiValue(PropertyId.Tasks, _vehicle.VehicleTasks); }
private void TxtTradeInCost_TextChanged(object sender, TextChangedEventArgs e) { CalculateTotal_TextChanged(sender, e); double tradeIn = 0; if (Utilities.StringToDouble(TxtTradeInCost.Text, out tradeIn) && !tradeIn.Equals(0)) { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.CREATETRADEINFORMTASK)) { return; } } VehicleTask createTradeInTask = new VehicleTask(); string taskText = string.Format(Strings.CREATETRADEINFORMTASK, txtTradeInModel.Text, txtTradeInVIN.Text); createTradeInTask.Id = taskText; createTradeInTask.TaskVehicleId = _vehicle.Id; createTradeInTask.CreatedDate = DateTime.Today.Date.ToString("d"); createTradeInTask.Status = VehicleTask.StatusTypes.NotStarted.ToString(); createTradeInTask.AssignedTo = CacheManager.ActiveUser.Name.ToString(CultureInfo.InvariantCulture); createTradeInTask.Category = VehicleTask.TaskCategoryTypes.Documentation.ToString(); createTradeInTask.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(createTradeInTask); } else { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.CREATETRADEINFORMTASK)) { if (vehicleTask.Status != VehicleTask.StatusTypes.Completed.ToString()) _vehicle.VehicleTasks.Remove(vehicleTask); break; } } } _vehicle.SetMultiValue(PropertyId.Tasks, _vehicle.VehicleTasks); }
private void SaleDatePicker_LostFocus(object sender, RoutedEventArgs e) { DateTime saleDate = DateTime.Now; if (!DateTime.TryParse(_vehicle.GetValue(PropertyId.SaleDate), out saleDate) ) { //foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) //{ //if (vehicleTask.Id.Equals(Strings.SOLDCARCLEANINGTASK)) //{ // _vehicle.VehicleTasks.Remove(vehicleTask); // break; //} //} foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.DELETECARFROMADVERTISING)) { _vehicle.VehicleTasks.Remove(vehicleTask); break; } } foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.CARDELIVEREDTASK)) { _vehicle.VehicleTasks.Remove(vehicleTask); break; } } foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.SOLDCARMINISTRYTASK)) { _vehicle.VehicleTasks.Remove(vehicleTask); break; } } _vehicle.SetMultiValue(PropertyId.Tasks, _vehicle.VehicleTasks); return; } #region Delete Oil Cleaning foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.NEWCAROILCHANGETASK) && vehicleTask.Status != VehicleTask.StatusTypes.Completed.ToString()) { _vehicle.VehicleTasks.Remove(vehicleTask); break; } } #endregion #region Sold Car Ministry task bool soldCarMinistryTaskFound = false; foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.SOLDCARMINISTRYTASK)) { soldCarMinistryTaskFound = true; break; } } DateTime June2016 = new DateTime(2016, 06, 01); if (!soldCarMinistryTaskFound && saleDate != null && saleDate > June2016) { VehicleTask vehicleSoldMinistryTask = new VehicleTask(); vehicleSoldMinistryTask.Id = Strings.SOLDCARMINISTRYTASK; vehicleSoldMinistryTask.TaskVehicleId = _vehicle.Id; vehicleSoldMinistryTask.Priority = VehicleTask.TaskPriority.Priority0.ToString(); vehicleSoldMinistryTask.CreatedDate = DateTime.Today.Date.ToString("d"); vehicleSoldMinistryTask.Status = VehicleTask.StatusTypes.NotStarted.ToString(); vehicleSoldMinistryTask.AssignedTo = "Filip Mitrofanov"; vehicleSoldMinistryTask.Category = VehicleTask.TaskCategoryTypes.Other.ToString(); vehicleSoldMinistryTask.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(vehicleSoldMinistryTask); } #endregion #region Car Delivery Task bool carDeliveryTaskFound = false; foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.CARDELIVEREDTASK)) { carDeliveryTaskFound = true; break; } } if (!carDeliveryTaskFound) { VehicleTask vehicleDeliveredTask = new VehicleTask(); vehicleDeliveredTask.Id = Strings.CARDELIVEREDTASK; vehicleDeliveredTask.TaskVehicleId = _vehicle.Id; vehicleDeliveredTask.CreatedDate = DateTime.Today.Date.ToString("d"); vehicleDeliveredTask.Status = VehicleTask.StatusTypes.NotStarted.ToString(); vehicleDeliveredTask.AssignedTo = "Reyad Toma"; vehicleDeliveredTask.Category = VehicleTask.TaskCategoryTypes.Other.ToString(); vehicleDeliveredTask.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(vehicleDeliveredTask); } #endregion #region Delete car advertising task bool deleteCarFromAdvertisingTaskFound = false; foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.DELETECARFROMADVERTISING)) { deleteCarFromAdvertisingTaskFound = true; break; } } if (!deleteCarFromAdvertisingTaskFound) { VehicleTask deleteAdvertisingTask = new VehicleTask(); deleteAdvertisingTask.Id = Strings.DELETECARFROMADVERTISING; deleteAdvertisingTask.TaskVehicleId = _vehicle.Id; deleteAdvertisingTask.CreatedDate = DateTime.Today.Date.ToString("d"); deleteAdvertisingTask.Status = VehicleTask.StatusTypes.NotStarted.ToString(); deleteAdvertisingTask.AssignedTo = "Mathew Toma"; deleteAdvertisingTask.Category = VehicleTask.TaskCategoryTypes.Detail.ToString(); deleteAdvertisingTask.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(deleteAdvertisingTask); } #endregion _vehicle.SetMultiValue(PropertyId.Tasks, _vehicle.VehicleTasks); }
private void PayoutLien_TextChanged(object sender, TextChangedEventArgs e) { CalculateTotal_TextChanged(sender, e); double payoutLien = 0; if (!Utilities.StringToDouble(_vehicle.GetValue(PropertyId.SalePayoutLienOnTradeIn), out payoutLien) || Math.Abs(payoutLien) == 0.0) { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.PAYOUTLIENTASK)) { _vehicle.VehicleTasks.Remove(vehicleTask); break; } } } else { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.PAYOUTLIENTASK)) { return; } } VehicleTask payoutLienTask = new VehicleTask(); payoutLienTask.Id = Strings.PAYOUTLIENTASK; payoutLienTask.TaskVehicleId = _vehicle.Id; payoutLienTask.CreatedDate = DateTime.Today.Date.ToString("d"); payoutLienTask.Status = VehicleTask.StatusTypes.NotStarted.ToString(); payoutLienTask.AssignedTo = "Reyad Toma"; payoutLienTask.Category = VehicleTask.TaskCategoryTypes.Finance.ToString(); payoutLienTask.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(payoutLienTask); } _vehicle.SetMultiValue(PropertyId.Tasks, _vehicle.VehicleTasks); }
private void LienRegistrationFee_TextChanged(object sender, TextChangedEventArgs e) { CalculateTotal_TextChanged(sender, e); double leinRegistrationFee = 0; if (!Utilities.StringToDouble(TxtLienRegistrationFee.Text, out leinRegistrationFee) || Math.Abs(leinRegistrationFee) == 0.0) { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.VERIFYFINANCEDEPOSIT)) { _vehicle.VehicleTasks.Remove(vehicleTask); break; } } } else { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.VERIFYFINANCEDEPOSIT)) { return; } } VehicleTask verifyFinanceDepositTask = new VehicleTask(); verifyFinanceDepositTask.Id = Strings.VERIFYFINANCEDEPOSIT; verifyFinanceDepositTask.TaskVehicleId = _vehicle.Id; verifyFinanceDepositTask.CreatedDate = DateTime.Today.Date.ToString("d"); verifyFinanceDepositTask.Status = VehicleTask.StatusTypes.NotStarted.ToString(); verifyFinanceDepositTask.AssignedTo = "Reyad Toma"; verifyFinanceDepositTask.Category = VehicleTask.TaskCategoryTypes.Finance.ToString(); verifyFinanceDepositTask.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(verifyFinanceDepositTask); } _vehicle.SetMultiValue(PropertyId.Tasks, _vehicle.VehicleTasks); }
private void cmbSafetyCertificate_SelectionChanged(object sender, SelectionChangedEventArgs e) { double tradeIn = 0; if (cmbSafetyCertificate.SelectedItem == null) return; if (cmbSafetyCertificate.SelectedItem.ToString() == Certified.No.ToString()) { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.ENSUREVEHICLEHASTRADEINFORM)) { return; } } VehicleTask createTradeInTask = new VehicleTask(); string taskText = string.Format(Strings.ENSUREVEHICLEHASTRADEINFORM, _vehicle.Model, _vehicle.VinNumber); createTradeInTask.Id = taskText; createTradeInTask.TaskVehicleId = _vehicle.Id; createTradeInTask.CreatedDate = DateTime.Today.Date.ToString("d"); createTradeInTask.Status = VehicleTask.StatusTypes.NotStarted.ToString(); createTradeInTask.AssignedTo = CacheManager.ActiveUser.Name.ToString(CultureInfo.InvariantCulture); createTradeInTask.Category = VehicleTask.TaskCategoryTypes.Documentation.ToString(); createTradeInTask.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(createTradeInTask); } else { foreach (VehicleTask vehicleTask in _vehicle.VehicleTasks) { if (vehicleTask.Id.Equals(Strings.ENSUREVEHICLEHASTRADEINFORM)) { if (vehicleTask.Status != VehicleTask.StatusTypes.Completed.ToString()) _vehicle.VehicleTasks.Remove(vehicleTask); break; } } } _vehicle.SetMultiValue(PropertyId.Tasks, _vehicle.VehicleTasks); }
private void btnCompleteTask_Click(object sender, RoutedEventArgs e) { VehicleTask task = VehicleListView.Items.Cast<VehicleTask>().FirstOrDefault(vehicleTask => vehicleTask.Id.Trim() == txtTaskId.Text.Trim()); if (task == null) return; if (!task.AssignedTo.Equals(CacheManager.ActiveUser.Name) && !task.AssignedTo.Equals(CacheManager.UserCache.SystemAdminAccount.Name) && !CacheManager.ActiveUser.Name.Equals("Roger Toma") ) { MessageBox.Show(string.Format(Strings.CONTROL_MANAGEVEHICLETASKS_CANNOTCOMPLETETASK, task.AssignedTo), Strings.ERROR); return; } UpdateTaskBasedOnUi(task); task.Comments = txtComments.Text; task.ClosedBy = CacheManager.ActiveUser.Name; task.Status = VehicleTask.StatusTypes.Completed.ToString(); if (task.Id.Equals(Strings.NEWCARCLEANINGTASK) && !string.IsNullOrEmpty(task.Comments)) { VehicleTask newCleanTaskResults = new VehicleTask(); newCleanTaskResults.Id = string.Format(Strings.USERLEFTCOMMENTSTASK, CacheManager.ActiveUser.Name); newCleanTaskResults.TaskVehicleId = _vehicle.Id; newCleanTaskResults.CreatedDate = DateTime.Today.Date.ToString("d"); newCleanTaskResults.Status = VehicleTask.StatusTypes.NotStarted.ToString(); newCleanTaskResults.Comments = task.Comments; newCleanTaskResults.AssignedTo = "Mathew Toma"; newCleanTaskResults.Category = VehicleTask.TaskCategoryTypes.Detail.ToString(); newCleanTaskResults.CreatedBy = CacheManager.ActiveUser.Name; _vehicle.VehicleTasks.Add(newCleanTaskResults); VehicleListView.Items.Add(newCleanTaskResults); } VehicleListView.Items.Refresh(); VehicleListView.ForceXmlUpdate(); VehicleListView.SelectedIndex = -1; }
private void UpdateTaskBasedOnUi(VehicleTask task) { task.Id = txtTaskId.Text; task.TaskVehicleId = _vehicle.Id; if (cmbStatus.SelectedIndex == -1) { task.Status = VehicleTask.StatusTypes.NotStarted.ToString(); UpdateComboBoxWithSelection(cmbStatus, VehicleTask.StatusTypes.NotStarted.ToString()); } else { task.Status = ((Label)cmbStatus.SelectedItem).Content.ToString(); } if (cmbAssignedTo.SelectedIndex == -1) { task.AssignedTo = CacheManager.UserCache.SystemAdminAccount.Name; UpdateComboBoxWithSelection(cmbAssignedTo, CacheManager.UserCache.SystemAdminAccount.Name); } else { task.AssignedTo = ((Label)cmbAssignedTo.SelectedItem).Content.ToString(); } if (cmbPriority.SelectedIndex == -1) { task.Category = VehicleTask.TaskPriority.Priority2.ToString(); UpdateComboBoxWithSelection(cmbCategory, VehicleTask.TaskPriority.Priority2.ToString()); } else { task.Priority = ((Label)cmbPriority.SelectedItem).Content.ToString(); } if (cmbCategory.SelectedIndex == -1) { task.Category = VehicleTask.TaskCategoryTypes.Other.ToString(); UpdateComboBoxWithSelection(cmbCategory, VehicleTask.TaskCategoryTypes.Other.ToString()); } else { task.Category = ((Label)cmbCategory.SelectedItem).Content.ToString(); } if (cmbCreatedBy.SelectedIndex == -1) { task.CreatedBy = CacheManager.ActiveUser.Name; UpdateComboBoxWithSelection(cmbCreatedBy, CacheManager.ActiveUser.Name); } else { task.CreatedBy = ((Label)cmbCreatedBy.SelectedItem).Content.ToString(); } if (cmbCompletedBy.SelectedIndex != -1) { task.ClosedBy = ((Label)cmbCompletedBy.SelectedItem).Content.ToString(); } if (dpCreatedDate.SelectedDate == null) { task.CreatedDate = DateTime.Today.Date.ToString("d"); } else { task.CreatedDate = ((DateTime)dpCreatedDate.SelectedDate).ToString("d"); } if (dpDueDate.SelectedDate != null) { task.DueDate = ((DateTime)dpDueDate.SelectedDate).ToString("d"); } task.Cost = txtCost.Text; task.Comments = txtComments.Text; task.Minutes = txtMinutes.Text; }
private void btnCreate_Click(object sender, RoutedEventArgs e) { VehicleTask task = new VehicleTask(); UpdateTaskBasedOnUi(task); _vehicle.VehicleTasks.Add(task); VehicleListView.Items.Add(task); VehicleListView.SelectedIndex = VehicleListView.Items.Count - 1; VehicleListView.Items.Refresh(); VehicleListView.ForceXmlUpdate(); VehicleListView.SelectedIndex = -1; }