private void BtnDeleteVacationOnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var img = sender as Image; if (img != null) { var row = img.DataContext as TblVacationViewModel; _viewModel.DeleteVacation(row); } }
private void MainGrid_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Down) { //var currentRowIndex = (_viewModel.SelectedMainRow.SelectedVacations.IndexOf(_viewModel.selectedVacation)); //if (currentRowIndex == (_viewModel.SelectedMainRow.SelectedVacations.Count - 1)) //{ // var newexe = new TblVacationViewModel(); // if (_viewModel.SelectedMainRow.EmpId == LoggedUserInfo.Code) // { // newexe.Status = _viewModel.VacationStatusSelfVisibility == Visibility.Visible ? 1 : 0; // newexe.VacationStatusVisibility = _viewModel.VacationStatusSelfVisibility; // } // else // { // newexe.Status = _viewModel.VacationStatusVisibility == Visibility.Visible ? 1 : 0; // newexe.VacationStatusVisibility = _viewModel.VacationStatusVisibility; // } // newexe.Emplid = _viewModel.SelectedMainRow.EmpId; // _viewModel.SelectedMainRow.SelectedVacations.Add(newexe); //} } else if (e.Key == Key.Delete) { if (_viewModel.selectedVacation.Iserial != 0) { _viewModel.DeleteVacation(_viewModel.selectedVacation); } else { if (_viewModel.SelectedMainRow.SelectedVacations.Count(x => x.FromDate == _viewModel.selectedVacation.FromDate) > 1) { _viewModel.SelectedMainRow.SelectedVacations.Remove(_viewModel.selectedVacation); } } } }