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