Exemple #1
0
        /// <summary>
        /// Здесь пока все в куче: поднятие/создание объекта, загрузка справочников для списков, настройка внешнего вида...
        /// </summary>
        void initForm()
        {
            if (edit)
            {
                currentOperations = uow.GetObjectByKey <device_Operations>(currentOperationsGuid);
            }
            else
            {
                currentOperations = new device_Operations(uow);
            }

            #region Настройка внешнего вида
            if (edit)
            {
                Text           = string.Format("Редактировать операцию {0} ", currentOperations.NameOperations);
                addButton.Text = "Сохранить";
            }

            if (view)
            {
                Text = string.Format("Просмотр операцию {0} ", currentOperations.NameOperations);
                nameOperationsTextEdit.ReadOnly        = true;
                typeOperationsGUIDLookUpEdit1.ReadOnly = true;
                timeEdit1.ReadOnly = true;
                workTeamGUIDLookUpEdit.ReadOnly = true;
                layoutControlItem7.Visibility   = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            }
            #endregion


            #region Заполнение выпадающего списка данными
            using (Session u = new Session())
            {
                SelectedData typeOperationsGUIDData = u.ExecuteQuery(@"SELECT GUID,NameOperationsType FROM [device].TypeOperations WHERE[DeletedDate] is null");
                typeOperationsGUIDDataView.LoadData(typeOperationsGUIDData);
            }
            using (Session u = new Session())
            {
                SelectedData workTeamGUID = u.ExecuteQuery(@"SELECT GUID,NumberOfWorkers  FROM [device].WorkTeam WHERE[DeletedDate] is null");
                workTeamGUIDDataView.LoadData(workTeamGUID);
            }
            #endregion

            if (edit)
            {
                nameOperationsTextEdit.Text             = currentOperations.NameOperations;
                typeOperationsGUIDLookUpEdit1.EditValue = currentOperations.TypeOperationsGUID;
                timeEdit1.Text = currentOperations.OperationTime.ToString();
                workTeamGUIDLookUpEdit.EditValue = currentOperations.WorkTeamGUID;
            }
        }
 private void barButtonItemDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     using (UnitOfWork u = new UnitOfWork())
     {
         device_Operations currentOperations = u.GetObjectByKey <device_Operations>((Guid)operationsGridView.GetFocusedRowCellValue("GUID"));
         DialogResult      d = XtraMessageBox.Show(string.Format("Удалить Измеряемые величины {0}  ?", currentOperations.NameOperations), "Подтверждение действия", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (d == DialogResult.Yes)
         {
             currentOperations.DeletedDate = DateTime.Now;
             currentOperations.Save();
             u.CommitChanges();
         }
     }
     loadData();
 }