示例#1
0
        private void EditPrice_Click(object sender, RoutedEventArgs e)
        {
            //Get button control
            Button Control = (Button)sender;

            var PriceData = NovaAPI.APIPrice.price.Find(x => x.id == Control.Tag.ToString());

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

            //Set category information to controls
            PriceNameTX.Text          = PriceData.name;
            PriceTypeCB.SelectedIndex = Convert.ToInt32(PriceData.type);
            PriceTypeCB.IsEnabled     = false;
            PriceValueTX.Text         = PriceData.value;


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

            //Focus editable category
            PriceNameTX.Focus();
            SavePriceBT.IsEnabled = true;
        }
示例#2
0
 private void ResetPriceForm()
 {
     PriceSelectIndex = "";
     PriceNameTX.Clear();
     PriceTypeCB.SelectedIndex = 0;
     PriceValueTX.Text         = "0";
     PriceValueTX.IsEnabled    = false;
     PriceTypeCB.IsEnabled     = true;
     SavePriceBT.IsEnabled     = false;
 }
示例#3
0
 private void NewPriceBT_Click(object sender, RoutedEventArgs e)
 {
     //From grid animation
     if (PriceFormGrid.Opacity == 0)
     {
         PriceFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid"));
         PriceNameTX.Focus();
         SavePriceBT.IsEnabled = true;
     }
     else if (PriceNameTX.Text.Length == 0)
     {
         PriceFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
         ResetPriceForm();
         SavePriceBT.IsEnabled = false;
     }
     //Clear price form values
     if (PriceNameTX.Text.Length > 0)
     {
         ResetPriceForm();
     }
 }
示例#4
0
        private async void SavePriceBT_Click(object sender, RoutedEventArgs e)
        {
            NewPriceBT.Focus();

            if (PriceNameTX.Text.Length == 0 || PriceNameTX.Text.Length < 4)
            {
                MessageBox.Show("El nombre de la categoria no puede estar en blanco o ser inferior a 4 caracteres");
                PriceNameTX.Focus();
                return;
            }

            int value = Convert.ToInt32(PriceValueTX.Text);

            if (value > 100)
            {
                MessageBox.Show("El rango del valor debe estar entre 0 - 100 %");
                PriceValueTX.Focus();
                return;
            }

            //Get/Set Category parameters
            var Data = new NovaAPI.APIPrice.PriceClass();

            Data.id    = PriceSelectIndex;
            Data.name  = PriceNameTX.Text;
            Data.type  = PriceTypeCB.SelectedIndex.ToString();
            Data.value = PriceValueTX.Text;


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

            bool response;

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

            //Request response
            if (response)
            {
                if (Data.id.Length > 0)
                {
                    ////On Category modified
                    var PriceData = NovaAPI.APIPrice.price.Find(x => x.id == Data.id);
                    PriceData.name  = Data.name;
                    PriceData.value = Data.value;
                    PricesGrid.Items.Refresh();
                    PriceFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    ResetPriceForm();
                }
                else
                {
                    //On new category created response
                    var PriceData = new NovaAPI.APIPrice.PriceClass();
                    PriceData.name  = Data.name;
                    PriceData.type  = Data.type;
                    PriceData.value = Data.value;
                    PriceData.id    = NovaAPI.APISupplier.LastID;

                    PriceFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    ResetPriceForm();

                    NovaAPI.APIPrice.price.Add(PriceData);

                    //Reload rol data
                    LoadPrices();
                }
            }
            else
            {
                MessageBox.Show($"Error al crear la categoria, INFO: {Environment.NewLine}{NovaAPI.APIPrice.Message}");
            }
        }