/// <summary> /// /// </summary> /// <param name="action"></param> /// <returns></returns> public virtual Control AddAction(ActionMetaItem action) { Control actionControl = null; if (!IsActionVisible(action)) { return(null); } //если это кастомная кнопка, то определим для неё функцию if (action.ActionType.Equals(ActionTypes.Action) && (BasePanel != null)) { var kvpFirst = BasePanel.GetFirstUIFunc(action.Name); var kvpSecond = BasePanel.GetSecondUIFunc(action.Name); if (kvpFirst.Key != null) { action.AddFirstUIFunc(kvpFirst.Key, kvpFirst.Value); } if (kvpSecond.Key != null) { action.AddSecondUIFunc(kvpSecond.Key, kvpSecond.Value); } } //если не надо группировать действие, то просто рендерим его как кнопку if (String.IsNullOrEmpty(action.Container) && action.ActionType != ActionTypes.Container) { #region Создание обычной кнопки //создаём кнопки для каждого действия var button = new SimpleButton { Name = String.Format("btn{0}", action.Name), }; InitButton(button, action); button.Tag = action; button.Click += OnButtonClick; m_Buttons.Add(button); //TODO может быть добавить дополнительную очистку списка в Dispose actionControl = button; #endregion if (BusinessObject != null) { SetButtonEnbabled(button, BusinessObject, action); BusinessObject.PropertyChanged += (sender, args) => SetButtonEnbabled(button, BusinessObject, action); BusinessObject.AfterPost += (sender, args) => SetButtonEnbabled(button, BusinessObject, action); } if (!Controls.Contains(actionControl)) { Controls.Add(actionControl); } } return(actionControl); }
/// <summary> /// Добавление произвольных действий /// </summary> public override void SetCustomActions(List <ActionMetaItem> actions) { base.SetCustomActions(actions); var action1 = new ActionMetaItem("action1", ActionTypes.Action, true, null, null, null, null, null); var action2 = new ActionMetaItem("action2", ActionTypes.Action, true, null, null, null, null, null); var action3 = new ActionMetaItem("action3", ActionTypes.Action, true, null, null, null, null, null); var action4 = new ActionMetaItem("action4", ActionTypes.Action, true, null, null, null, null, null); /* * var action1 = new ActionMetaItem("action1", "This is action1", "row_add" * , "Press me (action1)", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Left, ActionsPanelType.Main, ActionsAppType.All * , true, true, false, Action1Function, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, * "group1"); * * var action2 = new ActionMetaItem("action2", "This is action2", "row_delete" * , "Press me (action2)", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Left, ActionsPanelType.Main, ActionsAppType.All * , true, true, false, Action2Function, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, * "group1"); * * var action3 = new ActionMetaItem("action3", "This is action3", "paste" * , "Press me (action3)", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Right, ActionsPanelType.Top, ActionsAppType.All * , true, true, false, Action1Function, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, * "group2"); * * var action4 = new ActionMetaItem("action4", "This is action4", "refresh" * , "Press me (action4)", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Right, ActionsPanelType.Top, ActionsAppType.All * , true, true, false, Action2Function, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, * "group2"); */ AddCustomAction(action1); AddCustomAction(action2); AddCustomAction(action3); AddCustomAction(action4); }
/// <summary> /// /// </summary> /// <param name="panel"></param> /// <param name="action"></param> /// <param name="bo"></param> /// <param name="cancel"></param> internal void OnBeforeActionExecutingRaised(IBasePanel panel, ActionMetaItem action, IObject bo, ref bool cancel) { if (OnBeforeActionExecuting != null) { OnBeforeActionExecuting(panel, action, bo, ref cancel); } }
/// <summary> /// /// </summary> /// <param name="panel"></param> /// <param name="action"></param> /// <param name="bo"></param> internal void OnAfterActionExecutedRaised(IBasePanel panel, ActionMetaItem action, IObject bo) { if (OnAfterActionExecuted != null) { OnAfterActionExecuted(panel, action, bo); } }
/// <summary> /// /// </summary> /// <param name="action"></param> /// <returns></returns> public override Control AddAction(ActionMetaItem action) { var actionControl = base.AddAction(action); //если это действие принадлежит группе, то добавляем его в группу if ((actionControl == null) && (!string.IsNullOrEmpty(action.Container)) || action.ActionType == ActionTypes.Container) { //иначе отыскиваем или создаём группу и помещаем туда это действие #region Добавление действия в группу var actionGroup = GetActionGroup(action.ActionType == ActionTypes.Container ? action.Name : action.Container); actionGroup.AddAction(action, true); SetControlWidth(actionGroup.Button); actionControl = actionGroup.Button; #endregion if (!Controls.Contains(actionControl)) { Controls.Add(actionControl); } } return(actionControl); }
/// <summary> /// Типовое действие "Сохранить" /// </summary> /// <param name="action"> </param> /// <param name="saveOnly">true-выполняется действие Save, false-выполняется действие OK</param> private bool ActionSave(ActionMetaItem action, bool saveOnly) { if (!BusinessObject.HasChanges) { return(true); } var form = FindForm(); if (form != null) { form.BringToFront(); } var canProceed = saveOnly ? WinUtils.ConfirmSave() : WinUtils.ConfirmOk(); if (!canProceed) { return(false); } using (new WaitDialog(WaitDialogType.FormSaving)) { using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { return(action.RunAction(manager, BusinessObject).result); } } }
internal void RaiseAfterActionExecuted(ActionMetaItem action, IObject bo) { if (OnAfterActionExecuted != null) { OnAfterActionExecuted(ParentLayout != null ? ParentLayout.ParentBasePanel : null, action, bo); } }
private bool IsStandardAction(ActionMetaItem action) { return(action.ActionType == ActionTypes.Ok || action.ActionType == ActionTypes.Cancel || action.ActionType == ActionTypes.Save || action.ActionType == ActionTypes.Refresh || action.ActionType == ActionTypes.Close || action.ActionType == ActionTypes.Select || action.ActionType == ActionTypes.SelectAll); }
/// <summary> /// Возвращает последнее выполненное действие на любой панели, которая находится на том же Layout, что и эта панель /// </summary> /// <returns></returns> public ActionMetaItem GetLastExecutedAction() { ActionMetaItem result = null; if (ParentLayout != null) { result = ParentLayout.LastExecutedAction; } return(result); }
/// <summary> /// Удаляет действие из коллекции /// </summary> /// <param name="action"></param> public void DeleteAction(ActionMetaItem action) { if (Actions.Contains(action)) { //отыскиваем соответствующую кнопку if (ButtonLinks.ContainsKey(action)) { m_PopupActions.RemoveLink(ButtonLinks[action]); Actions.Remove(action); ButtonLinks.Remove(action); } } }
private void InitButton(SimpleButton btn, ActionMetaItem action) { btn.Text = GetMessage(action.CaptionId(BusinessObject, Permissions)); btn.Image = ImagesStorage.Get(action.IconId(BusinessObject, Permissions)); if (!string.IsNullOrEmpty(action.TooltipId(BusinessObject, Permissions))) { var superToolTip = new SuperToolTip(); //TODO получать текст специальным методом superToolTip.Items.Add(GetMessage(action.TooltipId(BusinessObject, Permissions))); btn.SuperTip = superToolTip; } SetControlWidth(btn); }
/// <summary> /// /// </summary> /// <param name="action"></param> /// <param name="needAddAction"></param> public void AddAction(ActionMetaItem action, bool needAddAction) { int index = Actions.Count; var image = ImagesStorage.Get(action.IconId(BusinessObject, Permissions)); if (action.ActionType == ActionTypes.Container) { m_ButtonMain.Tag = action; m_ButtonMain.Text = GetCaption(action.CaptionId(BusinessObject, Permissions)); m_ButtonMain.Name = String.Format("btn{0}", action.Name); if (image != null) { m_ButtonMain.Image = image; } if (!string.IsNullOrEmpty(action.TooltipId(BusinessObject, Permissions))) { var superToolTip = new SuperToolTip(); //TODO получать текст специальным методом superToolTip.Items.Add(GetCaption(action.TooltipId(BusinessObject, Permissions))); m_ButtonMain.SuperTip = superToolTip; } return; } var button = new BarButtonItem(m_PopupActions.Manager, GetCaption(action.CaptionId(BusinessObject, Permissions))) { Id = index, Tag = action }; if (image != null) { button.Glyph = image; } button.ItemClick += OnButtonItemClick; button.Enabled = action.IsEnable(BusinessObject, BusinessObject.GetPermissions()); ButtonLinks.Add(action, m_PopupActions.AddItem(button)); if (needAddAction) { Actions.Add(action); } //TODO правильно ли следующее if (String.IsNullOrEmpty(m_ButtonMain.Text) && Actions.Count >= 1) { m_ButtonMain.Tag = Actions[0]; m_ButtonMain.Text = GetCaption(Actions[0].Container); } }
public void RunActionShowFormTest() { TestTable testTable = TestTable.CreateInstance(); TestTable.Accessor accessor = TestTable.Accessor.Instance(null); //наполняем тестовыми действиями var action = new ActionMetaItem("Action1", ActionTypes.Action, true, null, null, null, null, null); /* * var action = new ActionMetaItem("Action1", "Show another form", "icon 1", "tooltip 1", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Right, * ActionsPanelType.Main, ActionsAppType.All, true, true, false, null, null, null, ActionTypes.ShowForm, ActionTypes.ShowForm, ActionTypes.Unknown, String.Empty) * {BasePanelTypeName = "TestPanelAdvancedUI"}; * accessor.Actions.Add(action); */ //TODO здесь должен быть BaseFormManager, который создаст Layout и поместит на него панель var pn = SetTestPanelUIBO(testTable); object id = null; pn.LoadData(ref id); ILayout currentLayout = pn.GetLayout(); Control container; if (currentLayout != null) { currentLayout.AddControlToMainContainer(pn); currentLayout.AddActions(pn, testTable); container = (Control)currentLayout; } else { container = pn; } var frm = new Form { StartPosition = FormStartPosition.CenterScreen, Location = new Point(50, 50), Size = new Size(700, 600) }; frm.Controls.Add(container); container.Dock = DockStyle.Fill; frm.ShowDialog(); //BaseFormManager.ShowNormal(typeof(testPanelUI), null, null, 700, 500); //BaseFormManager.ShowNormal(typeof(TestTable), null, null, 700, 500); }
/// <summary> /// /// </summary> /// <param name="action"></param> /// <returns></returns> public override bool IsActionVisible(ActionMetaItem action) { if (!action.IsVisible(BusinessObject, Permissions)) { return(false); } switch (action.ActionType) { case ActionTypes.Create: return(!(BaseGridPanel != null && BaseGridPanel.InlineMode == InlineMode.UseNewRow)); case ActionTypes.Edit: return(BaseGridPanel != null && BaseGridPanel.InlineMode == InlineMode.None); default: return(base.IsActionVisible(action)); } }
/// <summary> /// Добавление произвольных действий /// </summary> public override void SetCustomActions(List <ActionMetaItem> actions) { base.SetCustomActions(actions); var action1 = new ActionMetaItem("action1", ActionTypes.Action, true, null, null, null, null, null); var action2 = new ActionMetaItem("action2", ActionTypes.Action, true, null, null, null, null, null); /* * var action1 = new ActionMetaItem("action1", "This is action1", "icon 1" * , "Press me (action1)", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Left, ActionsPanelType.Main, ActionsAppType.All * , true, true, false, Action1Function, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, * String.Empty); * * var action2 = new ActionMetaItem("action2", "This is action2", "icon 2" * , "Press me (action2)", String.Empty, String.Empty, String.Empty, String.Empty, null, ActionsAlignment.Right, ActionsPanelType.Top, ActionsAppType.All * , true, true, false, Action2Function, null, null, ActionTypes.Action, ActionTypes.Action, ActionTypes.Unknown, * String.Empty); */ AddCustomAction(action1); AddCustomAction(action2); }
/// <summary> /// /// </summary> /// <param name="action"></param> /// <returns></returns> public virtual bool IsActionVisible(ActionMetaItem action) { if (BaseGridPanel != null && action.PanelType == ActionsPanelType.Top) { switch (BaseGridPanel.SelectMode) { case SelectMode.MultiSelect: return(action.ActionType == ActionTypes.SelectAll || action.ActionType == ActionTypes.Select); case SelectMode.SimpleSelect: return(action.ActionType == ActionTypes.Select); default: if (action.ActionType == ActionTypes.SelectAll || action.ActionType == ActionTypes.Select) { return(false); } return(action.IsVisible(BusinessObject, Permissions)); } } return(action.IsVisible(BusinessObject, Permissions)); }
/// <summary> /// </summary> /// <param name="key"></param> /// <param name="parameters"></param> /// <param name="actionType"></param> /// <param name="readOnly"></param> public override IApplicationForm Edit(object key, List <object> parameters, ActionTypes actionType, bool readOnly) { //TODO переписать метод более понятным IObject processedBusinessObject = null; var meta = ObjectAccessor.MetaInterface(BusinessObject.GetType()); if (key == null) { ActionMetaItem createAction = meta.Actions.Find(item => item.ActionType == ActionTypes.Create && item.PanelType == ActionsPanelType.Group); if (createAction == null) { return(this); } using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { var ret = createAction.RunAction(manager, m_DataSourceParent, parameters); if (ret.result) { processedBusinessObject = ret.obj; } } if (processedBusinessObject != null) { SetEnvironment(processedBusinessObject); if (InlineMode == InlineMode.UseCreateButton) { DataSource.Add(processedBusinessObject); for (var i = Grid.GridView.RowCount - 1; i >= 0; i--) { var row = Grid.GridView.GetRow(i); if (row.Equals(processedBusinessObject)) { Grid.GridView.FocusedRowHandle = i; } } } } } else { if (InlineMode == InlineMode.None) { ActionMetaItem editAction = meta.Actions.Find( item => item.ActionType == actionType && item.PanelType == ActionsPanelType.Group); if (editAction == null) { return(this); } using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { processedBusinessObject = editAction.IsCreate ? editAction.RunAction(manager, null as IObject, new List <object> { key }).obj : FocusedItem; } } } if ((InlineMode == InlineMode.None) && (processedBusinessObject != null)) { using (var manager = CreateDbManagerProxy()) { var clone = processedBusinessObject.CloneWithSetup(manager); #region В отдельном окне //для нового элемента FocusedItem == null var detailPanelName = GetDetailFormName(FocusedItem ?? BusinessObject); if (Utils.IsEmpty(detailPanelName)) { ErrorForm.ShowMessage("msgNoDetails", "msgNoDetails"); return(this); } var detailPanel = ClassLoader.LoadClass(detailPanelName); Dbg.Assert(detailPanel != null, "class {0} can't be loaded", detailPanelName); Dbg.Assert(detailPanel is IApplicationForm, "detail form {0} doesn't implement IApplicationFrom interface", detailPanelName); if (detailPanel is IBasePanel) { var appForm = detailPanel as IApplicationForm; if (readOnly) { clone.ReadOnly = true; (detailPanel as IBasePanel).ReadOnly = true; } /* * var layout = GetLayout() as LayoutEmpty; * if (layout != null) * { * var cancel = false; * layout.OnBeforeActionExecutingRaised(this, createAction ?? editAction, clone, ref cancel); * if (cancel) return this; * } */ BaseFormManager.ShowModal(appForm, clone); SetEnvironment(clone); //определяем действие, по которому закрылась форма if (appForm != null) { //если Ok, то заменяем клоном исходный объект LastExecutedActionInternal = appForm.GetLastExecutedAction(); if (LastExecutedActionInternal != null) { if (LastExecutedActionInternal.ActionType.Equals(ActionTypes.Ok) || LastExecutedActionInternal.ActionType.Equals(ActionTypes.Close) || (LastExecutedActionInternal.ActionType.Equals(ActionTypes.Action) && LastExecutedActionInternal.IsNeedClose) ) { var index = DataSource.IndexOf(processedBusinessObject); if (index < 0) { clone.DeepSetChange(); DataSource.Add(clone); } else { DataSource.ReplaceAndSetChange(processedBusinessObject as T, clone as T); } SetObjects(clone); Refresh(); } else { //видимо, происходит отмена. Надо дать возможность удалить временные объекты. DeleteTempObjects(processedBusinessObject); } } else { //видимо, происходит отмена. Надо дать возможность удалить временные объекты. DeleteTempObjects(processedBusinessObject); } } } #endregion } } return(this); }
/// <summary> /// /// </summary> /// <param name="action"></param> protected void AddCustomAction(ActionMetaItem action) { CustomActions.Add(action); }
/// <summary> /// /// </summary> /// <param name="action"></param> /// <param name="externalParams"> </param> internal virtual void RunAction(ActionMetaItem action, List <object> externalParams) { WaitDialogType waitType; switch (action.ActionType) { //case ActionTypes.Create: //case ActionTypes.Edit: //case ActionTypes.View: // waitType = WaitDialogType.FormLoading; // break; default: waitType = WaitDialogType.None; break; } if (!m_ActionLocker.Lock(waitType)) { return; } try { var needCancel = false; if (OnBeforeActionExecuting != null) { /* * IObject bo; * if (BaseGridPanel != null && BaseGridPanel.FocusedItem != null) * bo = BaseGridPanel.FocusedItem; * else * bo = BusinessObject; */ OnBeforeActionExecuting(ParentLayout != null ? ParentLayout.ParentBasePanel : null , action , BusinessObject , ref needCancel); } if (needCancel) { return; } //определим набор параметров, которые могут быть переданы от родительской панели //сначала получаем указатель на панель, которую обслуживает эта панель var parentBasePanel = ParentLayout != null ? ParentLayout.ParentBasePanel.ParentBasePanel : null; var parameters = externalParams; if (parentBasePanel != null && externalParams == null) { parameters = parentBasePanel.GetParamsAction(BusinessObject); } #region Выполнение действий var currentBo = BusinessObject; switch (action.ActionType) { case ActionTypes.Action: // For Grid panels only we should pass Key of Selected Item as parameter using (var manager = CreateDbManagerProxy()) { bool bSuccess; if (externalParams != null) { bSuccess = action.RunAction(manager, BusinessObject, externalParams).result; } else if ((BaseGridPanel != null)) { BaseGridPanel.RefreshFocusedItem(); currentBo = BaseGridPanel.FocusedItem; var prs = CreatePanelGridParameters(BaseGridPanel); prs.AddRange(action.Parameters); bSuccess = action.RunAction(manager, currentBo, prs).result; } else { bSuccess = action.RunAction(manager, BusinessObject).result; } if (bSuccess) { if (action.IsNeedClose) { ActionCloseForm(action.Name == "OK" ? DialogResult.OK : DialogResult.Cancel); } if (!String.IsNullOrEmpty(action.RelatedLists)) { var names = action.RelatedLists.Split(','); foreach (var name in names) { BaseFormManager.RefreshList(name); } } } } break; case ActionTypes.Create: if (BaseGridPanel != null) { BaseGridPanel.Edit(null, parameters, action.ActionType, false); currentBo = BaseGridPanel.FocusedItem; } else if ((ParentLayout != null) && (ParentLayout.ParentBasePanel != null)) { //TODO необходимо проверить этот код var saveAction = m_AllActions.SingleOrDefault(c => c.ActionType == ActionTypes.Save) ?? m_AllActions.SingleOrDefault(c => c.ActionType == ActionTypes.Ok); if (saveAction != null) { if (ActionSave(saveAction, true)) { using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { var bo = action.RunAction(manager, null as IObject, parameters).obj; if (bo != null) { currentBo = bo; ParentLayout.ParentBasePanel.BusinessObject = bo; ParentLayout.BusinessObject = bo; BusinessObject = bo; } } } } } break; case ActionTypes.Ok: //проверить наличие изменений + сохранить + закрыть форму var success = true; if (!BusinessObject.ReadOnly) { success = ActionSave(action, false); } if (success) { ActionCloseForm(DialogResult.OK); } break; case ActionTypes.Cancel: //проверить наличие изменений + не сохранять + закрыть форму if (ActionCanCancel()) { ActionCloseForm(); } break; case ActionTypes.Close: //закрыть форму var successClose = true; if (BusinessObject != null) { using (var manager = CreateDbManagerProxy()) { successClose = action.RunAction(manager, BusinessObject).result; } } if (successClose) { ActionCloseForm(); } break; case ActionTypes.Delete: //применяется только для списочных форм //проверить наличие активного элемента + сохранить + обновление if ((BaseGridPanel != null) && (BaseGridPanel.FocusedItem != null) && (ParentLayout != null)) { #region Для списочных форм /*if (BaseGridPanel.FocusedItem.HasChanges && !BaseGridPanel.FocusedItem.IsNew) * { * ErrorForm.ShowWarning("msgCantDelete", "Can't delete object"); * } * else*/ if (WinUtils.ConfirmDelete()) { BaseGridPanel.RefreshFocusedItem(); var itemsToDelete = BaseGridPanel.SelectedItems.Count > 0 ? BaseGridPanel.SelectedItems : new List <IObject> { BaseGridPanel.FocusedItem }; currentBo = BaseGridPanel.FocusedItem; try { var appForm = (parentBasePanel ?? ParentLayout.ParentBasePanel) as IApplicationForm; if ( BaseFormManager.FindFormByID(appForm, currentBo.Key) != null) { ErrorForm.ShowWarning("msgCantDelete", "Can't delete object"); break; } using (var manager = CreateDbManagerProxy()) { foreach (var item in itemsToDelete) { item.Validation += GridPanelItem_DeleteValidation; if (action.RunAction(manager, item).result) { if (!(BaseGridPanel is IChildListPanel)) { BaseFormManager.RefreshList(BusinessObject.GetType().Name); //BaseGridPanel.Delete(item.Key); } else { BaseGridPanel.Grid.GridView.BeginDataUpdate(); var filter = BaseGridPanel.Grid.GridView.ActiveFilter.NonColumnFilter; BaseGridPanel.Grid.GridView.ActiveFilter.NonColumnFilter = String.Empty; BaseGridPanel.Grid.GridView.ActiveFilter.NonColumnFilter = filter; BaseGridPanel.Grid.GridView.EndDataUpdate(); } if (!string.IsNullOrEmpty(action.RelatedLists)) { var names = action.RelatedLists.Split(','); foreach (var name in names) { if (name != BusinessObject.GetType().Name) { BaseFormManager.RefreshList(name); } } } } } } } finally { foreach (var item in itemsToDelete) { item.Validation -= GridPanelItem_DeleteValidation; } } } #endregion } else if ( (ParentLayout is LayoutSimple) && (BusinessObject != null) ) { if (!BusinessObject.IsNew && BusinessObject.HasChanges) { ErrorForm.ShowWarning("msgCantDelete", "Can't delete object"); } else if (WinUtils.ConfirmDelete()) { currentBo = BusinessObject; //if ( // BaseFormManager.FindFormByID(ParentLayout.ParentBasePanel as IApplicationForm, // currentBo.Key) != null) //{ // ErrorForm.ShowWarning("msgCantDelete", "Can't delete object"); // break; //} using (var manager = CreateDbManagerProxy()) { if (action.RunAction(manager, BusinessObject).result) { ActionCloseForm(); } } } } break; case ActionTypes.Refresh: //применяется только для списочных форм //получить данные из БД if (BaseGridPanel != null) { BaseGridPanel.Refresh(); } break; case ActionTypes.View: case ActionTypes.Edit: //применяется только для списочных форм //проверить наличие активного элемента + открыть форму редактирования (сохранения внутри неё) + обновить if (BaseGridPanel != null) { var readOnly = action.ActionType == ActionTypes.View || action.IsReadOnly(BusinessObject, Permissions); var focusedItem = BaseGridPanel.FocusedItem; if (BaseGridPanel.EnableMultiEdit && BaseGridPanel.SelectedItems.Count > 1) { var keys = BaseGridPanel.SelectedItems.Select(bo => bo.Key).ToList(); BaseGridPanel.Edit(keys, CreatePanelGridParameters(BaseGridPanel), action.ActionType, readOnly); } else if ((focusedItem != null) && (focusedItem.Key != null)) { currentBo = focusedItem; BaseGridPanel.Edit(focusedItem.Key, CreatePanelGridParameters(BaseGridPanel), action.ActionType, readOnly); } } break; case ActionTypes.Save: //проверить наличие изменений + сохранить ActionSave(action, true); break; case ActionTypes.Report: if ((ParentLayout != null) && (ParentLayout.ParentBasePanel != null)) { ParentLayout.ParentBasePanel.ShowReport(); } break; case ActionTypes.Select: if ((BaseGridPanel != null) && (BaseGridPanel.FocusedItem != null)) { ActionCloseForm(DialogResult.OK); } break; case ActionTypes.SelectAll: if (BaseGridPanel != null) { BaseGridPanel.SelectAll(); if (BaseGridPanel.SelectedItems != null && BaseGridPanel.SelectedItems.Count > 0) { ActionCloseForm(DialogResult.OK); } } break; } #endregion if (OnLastExecutedActionChanged != null) { OnLastExecutedActionChanged(action); } RaiseAfterActionExecuted(action, currentBo); } catch (PermissionException exc) { ErrorForm.ShowWarning("msgNoExecutePermission"); Dbg.Debug("Permission exception for {0}.{1}, exeption:{2}", exc.ObjectName, exc.ActionName, exc); } catch (ParamsCountException exc) { ErrorForm.ShowError(StandardError.ParamsCountError, exc); } catch (DbModelTimeoutException) { ErrorForm.ShowWarning("msgTimeoutList", "Cannot retrieve records from database because of the timeout. Please change search criteria and try again"); } catch (DbModelRaiserrorException ex2) { if (string.IsNullOrEmpty(ex2.MessageId)) { ErrorForm.ShowError(ex2.Message, ex2); } else { var args = ex2.MessageId.Split(new[] { ' ' }); if (args.Count() > 1) { var pars = new object[args.Count() - 1]; for (int i = 1; i < args.Count(); i++) { pars[i - 1] = args[i]; } ErrorForm.ShowError(args[0], args[0], pars); } else { ErrorForm.ShowError(ex2.MessageId, ex2.Message, ex2); } } } catch (DbModelException ex1) { if (string.IsNullOrEmpty(ex1.MessageId)) { ErrorForm.ShowError(ex1.Message, ex1); } else { ErrorForm.ShowError(ex1.MessageId, ex1.Message, ex1); } } catch (BvModelException exc) { ErrorForm.ShowError(StandardError.UnprocessedError, exc.InnerException ?? exc); } catch (Exception exc) { ErrorForm.ShowError(StandardError.UnprocessedError, exc); } finally { m_ActionLocker.Unlock(); } }
protected void SetButtonEnbabled(Control button, IObject bo, ActionMetaItem action) { button.Enabled = action.IsEnable(bo, bo.GetPermissions()); }
/// <summary> /// Последнее действие, выполненное на любой панели, располагающейся на этом Layout /// </summary> /// <param name="result"></param> void OnLastExecutedActionChanged(ActionMetaItem result) { LastExecutedAction = result; }