private void dataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e) { bool employeeWasClockedOut = false; e.Cancel = true; if (dataSet[dataGrid.SelectedIndex].IsLocked) { PosDialogWindow.ShowDialog( Strings.ThisRecordIsLockedAndCanNotBeChanged, Strings.EntryLocked); return; } if ((dataSet[dataGrid.SelectedIndex].GetEmployeeId() == SessionManager.ActiveEmployee.Id) && (dataSet[dataGrid.SelectedIndex].EndTime == null)) { PosDialogWindow.ShowDialog( Strings.ThisRecordIsYourCurrentClockInAndCanNotBeChangedUntilYouClockedOut, Strings.EmployeeNotClockedOut); return; } if (dataSet[dataGrid.SelectedIndex].EndTime == null) { if (PosDialogWindow.ShowDialog( Strings.ThisEmployeeMustClockOutBeforeYouCanEditWouldYouLikeToClockOutThisEmployeeRightNow, Strings.EmployeeNotClockedOut, DialogButtons.YesNo) == DialogButton.Yes) { DateTime endTime = DateTime.Now; dataSet[dataGrid.SelectedIndex].EndTime = endTime; dataSet[dataGrid.SelectedIndex].DeclaredTipAmount = 0; //dataSet[dataGrid.SelectedIndex].DriverCompensation = 0; employeeWasClockedOut = true; } else { return; } } // Show the dialog for editing a grid row PosDialogWindow window = TimesheetEditorControl.CreateInDefaultWindow(); TimesheetEditorControl control = window.DockedControl as TimesheetEditorControl; control.DataModel = dataSet[dataGrid.SelectedIndex]; window.ShowDialog(Window.GetWindow(this)); if (control.IsModelDeleted) { DeleteModel(control.DataModel); } else if (control.IsModelUpdated || employeeWasClockedOut) { UpdateModel(control.DataModel); } }
public static PosDialogWindow CreateInDefaultWindow() { TimesheetEditorControl control = new TimesheetEditorControl(); return(new PosDialogWindow(control, Strings.EditEntry, 760, 430)); }