void InitPage(CrudAPI crudapi, UnicontaBaseEntity master = null, bool isLastField = false)
 {
     if (!isLastField)
     {
         ribbonControl = frmRibbon;
         RibbonBase rb = (RibbonBase)frmRibbon.DataContext;
         UtilDisplay.RemoveMenuCommand(rb, new string[] { "Delete" });
     }
     this.master   = master;
     layoutControl = layoutItems;
     if (LoadedRow == null && master != null)
     {
         editrow            = CreateNew() as TableFieldsClient;
         editrow._FieldType = Uniconta.DataModel.CustomTypeCode.String;
         editrow.SetMaster(master);
     }
     BindRefTable(editrow._FieldType);
     layoutItems.DataContext  = editrow;
     frmRibbon.OnItemClicked += frmRibbon_OnItemClicked;
 }
Exemplo n.º 2
0
        static async Task MainAsync()
        {
            var key = new Guid("69a53f30-a1b0-4d79-b6ea-ba2d36e1585f");

            #region LOGIN-PROCESS
            var con = new UnicontaConnection(APITarget.Live);
            var ses = new Session(con);

            Console.Write("Username: "******"Password: "******"Unable to login: "******"Login success: Logged in as {ses.User._Name}\n");
            #endregion

            #region SELECT-COMPANY

            Console.Write("Enter company ID: ");
            var cmpString = Console.ReadLine();
            if (!int.TryParse(cmpString, out int cmpId))
            {
                Console.WriteLine("Not a number");
                Exit();
            }

            var cmp = await ses.OpenCompany(cmpId, false);

            Console.WriteLine($"Company selected: {cmp.Name}");

            var crud = new CrudAPI(ses, cmp);

            var debtors = await crud.Query <DebtorClient>();

            Console.Write("Expression = [search] [query]");
            var expression = Console.ReadLine();
            //var command = expression.Split()[0];
            //var param = expression.Split()[1];

            //switch (command)
            //{
            //    case "search":
            //        foreach (var d in debtors.Where(d => d.Name != null && d.Name.ToLower().Contains(param)))
            //        {
            //            Console.WriteLine($"{d.Account} | {d.Name}");
            //        }
            //        break;
            //}



            //Console.Write("Enter debtor account: ");
            //var debtorAccount = Console.ReadLine();

            //var debtor = new DebtorClient { Account = debtorAccount };
            //await crud.Read(debtor);

            //Console.Write("Enter item id: ");
            //var itemId = Console.ReadLine();

            //var item = new InvItemClient { Item = itemId };
            //await crud.Read(item);

            //Console.WriteLine("Generating sales order...");

            //DebtorOrderClient order = null;
            //order = (await crud.Query<DebtorOrderClient>(debtor)).FirstOrDefault();
            //if (order == null)
            //{
            //    order = new DebtorOrderClient { };
            //    order.SetMaster(debtor);
            //    await crud.Insert(order);
            //}


            //var orderLine = new DebtorOrderLineClient
            //{
            //    Item = item.Item,
            //    Qty = 1,
            //};
            //orderLine.SetMaster(order);
            //var fp = new FindPrices(order, crud);
            //fp.UseCustomerPrices = true;
            //fp.loadPriceList();
            //fp.SetPriceFromItem(orderLine, item);

            //await crud.Insert(orderLine);

            #endregion


            var newField = new TableFieldsClient
            {
                Name = "SomeField11",
            };
            newField.SetMaster(new DebtorOrderClient());
            var res = await crud.Insert(newField);

            Console.WriteLine(res);

            Exit();
            return;
        }