示例#1
0
        /// <summary>
        /// Инициализирует карточку по заданным данным.
        /// </summary>
        /// <param name="ClassBase">Скрипт карточки.</param>
        /// <param name="e">Событие открытия карточки</param>
        public ApplicationCard(ScriptClassBase ClassBase, CardActivatedEventArgs e)
            : base(ClassBase)
        {
            try
            {
                /* Получение рабочих объектов */
                Table_Service     = ICardControl.FindPropertyItem <ITableControl>(RefApplicationCard.Service.Alias);
                Table_AddComplete = ICardControl.FindPropertyItem <ITableControl>(RefApplicationCard.AddComplete.Alias);

                Grid_Service     = ICardControl.GetGridView(RefApplicationCard.Service.Alias);
                Grid_AddComplete = ICardControl.GetGridView(RefApplicationCard.AddComplete.Alias);

                Control_Links = ICardControl.FindPropertyItem <LinksControlView>(RefApplicationCard.MainInfo.Links);

                /* Получение номера */
                if (GetControlValue(RefApplicationCard.MainInfo.Number).ToGuid().IsEmpty())
                {
                    CurrentNumerator        = CardScript.GetNumber(RefApplicationCard.NumberRuleName);
                    CurrentNumerator.Number = Convert.ToInt32(CurrentNumerator.Number).ToString("00000");
                    SetControlValue(RefApplicationCard.MainInfo.Number, Context.GetObjectRef <BaseCardNumber>(CurrentNumerator).Id);
                    WriteLog("Выдали номер: " + CurrentNumerator.Number);
                }
                else
                {
                    CurrentNumerator = Context.GetObject <BaseCardNumber>(GetControlValue(RefApplicationCard.MainInfo.Number));
                }

                /* Заполнение списка изменений */
                RefreshChanges();

                /* Значения по умолчанию */
                if (e.ActivateFlags.HasFlag(ActivateFlags.New))
                {
                    SetControlValue(RefApplicationCard.MainInfo.Status, (Int32)RefApplicationCard.MainInfo.State.Registered);
                }

                if (GetControlValue(RefApplicationCard.MainInfo.Negotiator).ToGuid().IsEmpty())
                {
                    try
                    {
                        StaffEmployee Emp = Context.GetEmployeeByPosition("Начальник отдела настройки");
                        SetControlValue(RefApplicationCard.MainInfo.Negotiator, Context.GetObjectRef(Emp).Id);
                    }
                    catch { MyMessageBox.Show("Не удалось найти ответственного исполнителя!", "Предупржедение", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
                }

                /* Привязка методов */
                CardScript.CardControl.CardClosed += CardControl_CardClosed;
                CardScript.CardControl.Saved      += CardControl_Saved;
                CardScript.CardControl.Saving     += CardControl_Saving;
                ICardControl.RibbonControl.Items[RefApplicationCard.RibbonItems.ShowClientInfo].ItemClick     += ShowClientInfo_ItemClick;
                ICardControl.RibbonControl.Items[RefApplicationCard.RibbonItems.Calculation].ItemClick        += Calculation_ItemClick;
                ICardControl.RibbonControl.Items[RefApplicationCard.RibbonItems.PrintAcceptanceAct].ItemClick += PrintAcceptanceAct_ItemClick;
                ICardControl.RibbonControl.Items[RefApplicationCard.RibbonItems.PrintDeliveryAct].ItemClick   += PrintDeliveryAct_ItemClick;
                ICardControl.RibbonControl.Items[RefApplicationCard.RibbonItems.Calibrate].ItemClick          += Calibrate_ItemClick;
                ICardControl.RibbonControl.Items[RefApplicationCard.RibbonItems.Revoke].ItemClick             += Revoke_ItemClick;
                ICardControl.RibbonControl.Items[RefApplicationCard.RibbonItems.CreateAccountCard].ItemClick  += CreateAccountCard_ItemClick;
                ICardControl.RibbonControl.Items[RefApplicationCard.RibbonItems.Marketing].ItemClick          += Marketing_ItemClick;

                Grid_Service.AddDoubleClickHandler(new Service_DoubleClickDelegate(Service_DoubleClick));
                AddTableHandler(RefApplicationCard.Service.Alias, "AddButtonClicked", "Service_AddButtonClicked");
                AddTableHandler(RefApplicationCard.Service.Alias, "RemoveButtonClicked", "Service_RemoveButtonClicked");

                /* Настройка */
                Customize();
            }
            catch (Exception Ex) { CallError(Ex); }
        }