Пример #1
0
        //Set clients to searchbox
        private void SetClients()
        {
            //Set IEnumerable LIST
            IEnumerable <string> ClientList = Enumerable.Empty <string>();

            for (int i = 0; i < NovaAPI.APIClient.clients.Count; i++)
            {
                ClientList = ClientList.Concat(new[] { NovaAPI.APIClient.clients[i].name });
            }

            //Set list of clients to textbox
            ClientFilterTX.SetValue(AutoCompleteBehavior.AutoCompleteItemsSource, ClientList);

            ClientFilterTX.Focus();
        }
Пример #2
0
        //Save client information
        private async void SaveClientBT_Click(object sender, RoutedEventArgs e)
        {
            //Get/Set client parameters
            var Data = new NovaAPI.APIClient.ClientClass();

            Data.name       = ClientNameTX.Text;
            Data.type       = ClientIDType.SelectedIndex.ToString();
            Data.documentid = ClientIDTX.Text;
            Data.phone      = ClientPhoneTX.Text;
            Data.cancredit  = "0";
            Data.address    = "";
            Data.celphone   = "";

            try
            {
                NovaAPI.APIClient.clients.Clear();
            }
            catch (Exception)
            {
            }

            //rol json data
            string requestData = JsonConvert.SerializeObject(Data);

            bool response;

            //Modify / Create request
            response = await NovaAPI.APIClient.GetValues("1", DataConfig.LocalAPI, requestData);

            //Request response
            if (response)
            {
                var ClientData = new NovaAPI.APIClient.ClientClass();
                ClientData.name       = Data.name;
                ClientData.documentid = Data.documentid;
                ClientData.type       = Data.type;
                ClientData.address    = Data.address;
                ClientData.phone      = Data.phone;
                ClientData.mail       = Data.mail;
                ClientData.celphone   = Data.celphone;
                ClientData.cancredit  = Data.cancredit;
                ClientData.id         = NovaAPI.APIClient.LastID;

                NovaAPI.APIClient.clients.Add(ClientData);

                //Set IEnumerable LIST
                IEnumerable <string> ClientList = Enumerable.Empty <string>();

                for (int i = 0; i < NovaAPI.APIClient.clients.Count; i++)
                {
                    ClientList = ClientList.Concat(new[] { NovaAPI.APIClient.clients[i].name });
                }

                //Set list of clients to textbox
                ClientFilterTX.SetValue(AutoCompleteBehavior.AutoCompleteItemsSource, ClientList);

                ClientFilterTX.Text = ClientData.name;
                ClientFilterTX.Focus();

                ClientExitBT_Click(null, null);

                SearchClientBT_Click(null, null);
            }
            else
            {
                ClientExitBT_Click(null, null);
                MessageBox.Show($"Error al crear el cliente, INFO: {Environment.NewLine}{NovaAPI.APIClient.Message}");
            }
        }