Example #1
0
 //Set Supplier data
 private void SelectSupplier(NovaAPI.APISupplier.SupplierClass Data)
 {
     SocialnameLB.Content    = Data.socialname;
     ComercialNameLB.Content = Data.comercialname;
     IdLB.Content            = Data.idcomplete;
     PhonesLB.Content        = Data.phones;
     AddressLB.Content       = Data.address;
     ContactLB.Content       = Data.contact;
 }
Example #2
0
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            if (FormGrid.Opacity != 0)
            {
                ResetForm();
                FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
            }

            //Get button control
            Button Control = (Button)sender;


            //Get User information
            var Supplier = NovaAPI.APISupplier.suppliers.Find(x => x.id == Control.Tag.ToString());


            if (MessageBox.Show($"A continuación se eliminara el proveedor '{Supplier.comercialname}'{Environment.NewLine}¿Desea continuar?", "Eliminar proveedor", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                var Data = new NovaAPI.APISupplier.SupplierClass();
                Data.id = Supplier.id;

                //Delete user
                string requestData = JsonConvert.SerializeObject(Data);
                bool   response    = await NovaAPI.APISupplier.GetValues("3", DataConfig.LocalAPI, requestData);

                if (response)
                {
                    NovaAPI.APISupplier.suppliers.Remove(Supplier);
                    SuppliersGrid.Items.Refresh();
                }
                else
                {
                    MessageBox.Show($"Error al eliminar el proveedor, INFO: {Environment.NewLine}{NovaAPI.APISupplier.Message}");
                }
            }
        }
Example #3
0
        //Supplier create / modify functions
        private async void SaveBT_Click(object sender, RoutedEventArgs e)
        {
            NewSupplierBT.Focus();

            if (SuppSocialNameTX.Text.Length == 0 || SuppSocialNameTX.Text.Length < 5)
            {
                MessageBox.Show("La razón social no puede estar en blanco o ser inferior a 5 caracteres");
                SuppSocialNameTX.Focus();
                return;
            }
            else if (SuppIDTX.Text.Length == 0 || SuppIDTX.Text.Length < 5)
            {
                MessageBox.Show("El numero de identificacion no puede estar en blanco o ser inferior a 5 caracteres");
                SuppIDTX.Focus();
                return;
            }

            //Get/Set Supplier parameters
            var Data = new NovaAPI.APISupplier.SupplierClass();

            Data.id            = SelectedIndex;
            Data.socialname    = SuppSocialNameTX.Text;
            Data.comercialname = SuppComercialNameTX.Text.Length == 0 ? SuppSocialNameTX.Text : SuppComercialNameTX.Text;
            Data.idtype        = SuppidTypeCB.SelectedIndex.ToString();
            Data.documentid    = SuppIDTX.Text;
            Data.address       = SuppAddressTX.Text;
            Data.mail          = SuppEmailTX.Text;
            Data.phone         = SuppPhoneTX.Text;
            Data.celphone      = SuppCelphoneTX.Text;
            Data.contact       = SuppContactTX.Text;
            Data.observation   = SuppObvsTX.Text;
            Data.status        = StatusCB.IsChecked == true ? "1" : "0";


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

            bool response;

            //Modify / Create request
            if (Data.id.Length > 0)
            {
                response = await NovaAPI.APISupplier.GetValues("2", DataConfig.LocalAPI, requestData);
            }
            else
            {
                response = await NovaAPI.APISupplier.GetValues("1", DataConfig.LocalAPI, requestData);
            }

            //Request response
            if (response)
            {
                if (Data.id.Length > 0)
                {
                    //On supplier modified
                    var SuppData = NovaAPI.APISupplier.suppliers.Find(x => x.id == Data.id);
                    SuppData.socialname    = Data.socialname;
                    SuppData.comercialname = Data.comercialname;
                    SuppData.idtype        = Data.idtype;
                    SuppData.documentid    = Data.documentid;
                    SuppData.address       = Data.address;
                    SuppData.mail          = Data.mail;
                    SuppData.phone         = Data.phone;
                    SuppData.celphone      = Data.celphone;
                    SuppData.contact       = Data.contact;
                    SuppData.observation   = Data.observation;
                    SuppData.status        = Data.status;
                    SuppliersGrid.Items.Refresh();
                    FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    ResetForm();
                }
                else
                {
                    //On new supplier created response
                    var SuppData = new NovaAPI.APISupplier.SupplierClass();
                    SuppData.socialname    = Data.socialname;
                    SuppData.comercialname = Data.comercialname;
                    SuppData.idtype        = Data.idtype;
                    SuppData.documentid    = Data.documentid;
                    SuppData.address       = Data.address;
                    SuppData.mail          = Data.mail;
                    SuppData.phone         = Data.phone;
                    SuppData.celphone      = Data.celphone;
                    SuppData.contact       = Data.contact;
                    SuppData.status        = Data.status;
                    SuppData.observation   = Data.observation;
                    SuppData.id            = NovaAPI.APISupplier.LastID;

                    FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    ResetForm();

                    NovaAPI.APISupplier.suppliers.Add(SuppData);

                    //Reload rol data
                    LoadData();
                }
            }
            else
            {
                MessageBox.Show($"Error al crear el proveedor, INFO: {Environment.NewLine}{NovaAPI.APISupplier.Message}");
            }
        }