void Window1_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { DependencyObject dep = (DependencyObject)e.OriginalSource; while ((dep != null) && !(dep is DataGridCell)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) { return; } if (dep is DataGridCell) { DataGridCell cell = dep as DataGridCell; cell.Focus(); while ((dep != null) && !(dep is DataGridRow)) { dep = VisualTreeHelper.GetParent(dep); } DataGridRow row = dep as DataGridRow; dataService.SelectedItem = row.DataContext; Model.view.ServiceView RowData = (Model.view.ServiceView)dataService.SelectedItem; Disable_MenuItem.Header = RowData.STATUS == "Disabled" ? "Active" : "Disable Room"; } }
private void EditService(object sender, RoutedEventArgs e) { if (dataService.SelectedItems.Count > 0) { Model.view.ServiceView row = (Model.view.ServiceView)dataService.SelectedItem; Frm.EditService ES = new Frm.EditService(row.NAME, row.TYPE, row.PRICE); ES.ShowDialog(); GetServiceView(); } }
private void DisableService(object sender, RoutedEventArgs e) { if (dataService.SelectedItems.Count > 0) { Model.dao.ServiceDao sd = new Model.dao.ServiceDao(); Model.view.ServiceView RowData = (Model.view.ServiceView)dataService.SelectedItem; if (RowData.STATUS == "Active") { sd.ChangeStatus(2, RowData.NAME); } else { sd.ChangeStatus(1, RowData.NAME); } GetServiceView(); } }