Beispiel #1
0
 public ReferenceListsController(IReferenceListService referenceListService)
 {
     _referenceListService = referenceListService;
 }
Beispiel #2
0
        private void CreateAccountCard_ItemClick(Object sender, ItemClickEventArgs e)
        {
            try
            {
                IReferenceListService ReferenceListService = Context.GetService <IReferenceListService>();
                ReferenceList         RefList = Context.GetObject <ReferenceList>(Control_Links.ReferenceListID);
                if (RefList.References.Any(r => r.CardType.Equals(RefAccountCard.ID)))
                {
                    CardScript.CardFrame.CardHost.ShowCardModal(RefList.References.First(r => r.CardType.Equals(RefAccountCard.ID)).Card, ActivateMode.Edit);
                }

                if (Table_Service.RowCount > 0)
                {
                    throw new MyException(1);
                }

                if (!CardScript.SaveCard())
                {
                    throw new MyException(0);
                }

                /* Формирование задания на отгрузку */
                CardData AccountData = Context.CreateCard(RefAccountCard.ID);
                AccountData.BeginUpdate();

                RowData     MainInfoRow = AccountData.Sections[RefAccountCard.MainInfo.ID].FirstRow;
                SectionData Service     = AccountData.Sections[RefAccountCard.Service.ID];

                MainInfoRow.SetGuid(RefAccountCard.MainInfo.RegisterId, Context.GetCurrentUser());
                MainInfoRow.SetGuid(RefAccountCard.MainInfo.ContractSubjectId, AccountCard.Item_Subject_Service.ToGuid());
                MainInfoRow.SetGuid(RefAccountCard.MainInfo.ClientId, GetControlValue(RefApplicationCard.MainInfo.Client).ToGuid());


                Guid?RefListId = MainInfoRow.GetGuid(RefAccountCard.MainInfo.LinkListId);
                RefList = RefListId.HasValue ? Context.GetObject <ReferenceList>(RefListId.Value) : ReferenceListService.CreateReferenceList();

                if (!RefList.References.Any(RefRef => RefRef.Card.Equals(CardScript.CardData.Id)))
                {
                    ReferenceListService.CreateReference(RefList, null, CardScript.CardData.Id, RefApplicationCard.ID, false);
                    MainInfoRow.SetGuid(RefAccountCard.MainInfo.LinkListId, Context.GetObjectRef <ReferenceList>(RefList).Id);
                }

                RefList.References.First(RefRef => RefRef.Card.Equals(CardScript.CardData.Id)).LinkDescription = DateTime.Now.ToString("Создано dd.MM.yyyy HH:mm");
                Context.SaveObject(RefList);

                for (Int32 i = 0; i < Table_Service.RowCount; i++)
                {
                    BaseCardProperty Row        = Table_Service[i];
                    RowData          ServiceRow = Service.Rows.AddNew();
                    ServiceRow.SetGuid(RefAccountCard.Service.Id, Row[RefApplicationCard.Service.Id].ToGuid());
                    ServiceRow.SetGuid(RefAccountCard.Service.DeviceId, Row[RefApplicationCard.Service.DeviceID].ToGuid());
                    ServiceRow.SetBoolean(RefAccountCard.Service.AC, (Boolean)Row[RefApplicationCard.Service.Verify]);
                    ServiceRow.SetBoolean(RefAccountCard.Service.Verify, (Boolean)Row[RefApplicationCard.Service.Verify]);
                    ServiceRow.SetBoolean(RefAccountCard.Service.Repair, (Boolean)Row[RefApplicationCard.Service.Repair]);
                    ServiceRow.SetBoolean(RefAccountCard.Service.Calibrate, (Boolean)Row[RefApplicationCard.Service.Calibrate]);
                    ServiceRow.SetBoolean(RefAccountCard.Service.Delivery, false);
                    ServiceRow.SetInt32(RefAccountCard.Service.Count, 1);
                    ServiceRow.SetInt32(RefAccountCard.Service.Shipped, 0);
                    ServiceRow.SetInt32(RefAccountCard.Service.ToShip, 1);
                    ServiceRow.SetString(RefAccountCard.Service.ACList, Row[RefApplicationCard.Service.ACList]);
                    ServiceRow.SetString(RefAccountCard.Service.PackedListData, Row[RefApplicationCard.Service.PackedListData]);
                    ServiceRow.SetGuid(RefAccountCard.Service.PackedListId, Row[RefApplicationCard.Service.PackedListID].ToGuid());
                    ServiceRow.SetBoolean(RefAccountCard.Service.Warranty, (Boolean)Row[RefApplicationCard.Service.WarrantyServices]);
                }

                AccountData.EndUpdate();

                if (CardScript.CardFrame.CardHost.ShowCardModal(AccountData.Id, ActivateMode.Edit, ActivateFlags.New))
                {
                    Control_Links.AddRef(AccountData.Id, DateTime.Now.ToString("Создано dd.MM.yyyy HH:mm"), true, false);
                    MyHelper.SaveCard(CardScript);
                }
                else
                {
                    AccountData.ForceUnlock();
                    CardScript.Session.CardManager.DeleteCard(AccountData.Id, true);
                }
            }
            catch (MyException Ex)
            {
                switch (Ex.ErrorCode)
                {
                case 1: MyMessageBox.Show("Таблица «Сервисное обслуживание» не заполнена!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); break;
                }
            }
            catch (Exception Ex) { CallError(Ex); }
        }