Exemple #1
0
        private async void NewSupplierBT_Click(object sender, RoutedEventArgs e)
        {
            if (FilterGrid.Opacity != 0)
            {
                FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                await Task.Delay(100);
            }

            //From grid animation
            if (FormGrid.Opacity == 0)
            {
                FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid"));
                SuppSocialNameTX.Focus();
                SaveBT.IsEnabled = true;
            }
            else if (SuppSocialNameTX.Text.Length == 0)
            {
                FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                ResetForm();
            }
            //Clear supplier values
            if (SuppSocialNameTX.Text.Length > 0)
            {
                ResetForm();
            }
        }
Exemple #2
0
 //Reset form data
 private void ResetForm()
 {
     FilterTX.Clear();
     SuppSocialNameTX.Clear();
     SuppComercialNameTX.Clear();
     SuppIDTX.Clear();
     SuppidTypeCB.SelectedIndex = 0;
     SuppAddressTX.Clear();
     SuppPhoneTX.Clear();
     StatusCB.IsChecked = true;
     SuppCelphoneTX.Clear();
     SuppEmailTX.Clear();
     SuppContactTX.Clear();
     SuppObvsTX.Clear();
     SaveBT.IsEnabled = false;
 }
Exemple #3
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            //Hide filter
            if (FilterGrid.Opacity != 0)
            {
                FilterGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
            }

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

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

            if (FormGrid.Opacity == 0)
            {
                FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid"));
            }

            //Set supplier information to controls
            SuppSocialNameTX.Text      = Supplier.socialname;
            SuppComercialNameTX.Text   = Supplier.comercialname;
            SuppidTypeCB.SelectedIndex = Convert.ToInt32(Supplier.idtype);
            SuppIDTX.Text       = Supplier.documentid;
            SuppAddressTX.Text  = Supplier.address;
            SuppPhoneTX.Text    = Supplier.phone;
            SuppCelphoneTX.Text = Supplier.celphone;
            SuppEmailTX.Text    = Supplier.mail;
            SuppContactTX.Text  = Supplier.contact;
            SuppObvsTX.Text     = Supplier.observation;
            StatusCB.IsChecked  = Supplier.status == "1" ? true : false;


            //Set selected supplier id index for edition save
            SelectedIndex = Control.Tag.ToString();

            //Focus editable rol
            SuppSocialNameTX.Focus();
            SaveBT.IsEnabled = true;
        }
Exemple #4
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}");
            }
        }