void initForm() { if (edit) { currentWorkShifts = uow.GetObjectByKey <device_WorkShifts>(currentWorkShiftsGuid); } else { currentWorkShifts = new device_WorkShifts(uow); } #region Настройка внешнего вида if (edit) { Text = string.Format("Редактирование тип {0}", currentWorkShifts.TypeOfShift); addButton.Text = "Сохранить"; } if (view) { Text = string.Format("Просмотр тип {0}", currentWorkShifts.TypeOfShift); typeOfShiftTextEdit.ReadOnly = true; WorkingHoursTextEdit.ReadOnly = true; shiftTypeTextEdit.ReadOnly = true; layoutControlItem7.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } #endregion if (edit) { typeOfShiftTextEdit.Text = currentWorkShifts.TypeOfShift; WorkingHoursTextEdit.Text = currentWorkShifts.WorkingHours.ToString(); shiftTypeTextEdit.Text = currentWorkShifts.ShiftType; } }
private void barButtonItemDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { using (UnitOfWork u = new UnitOfWork()) { device_WorkShifts currentWorkShifts = u.GetObjectByKey <device_WorkShifts>((Guid)workShiftsGridView.GetFocusedRowCellValue("GUID")); DialogResult d = XtraMessageBox.Show(string.Format("Удалить тип ремонта {0}?", currentWorkShifts.TypeOfShift), "Подтверждение действия", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (d == DialogResult.Yes) { currentWorkShifts.DeletedDate = DateTime.Now; currentWorkShifts.Save(); u.CommitChanges(); } } loadData(); }