Beispiel #1
0
        private async void Delete_Click(object sender, RoutedEventArgs e)
        {
            if (BoxFormGrid.Opacity != 0)
            {
                BoxNameTX.Clear();
                BoxFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
            }

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

            //Get box information
            string BoxhName = NovaAPI.APIBoxes.boxes.Find(x => x.id == Control.Tag.ToString()).name;

            if (MessageBox.Show($"A continuación se eliminara el punto de venta '{BoxhName}{Environment.NewLine}¿Desea continuar?", "Eliminar punto de venta", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                var Data = new NovaAPI.APIBoxes.BoxesClass();
                Data.id = Control.Tag.ToString();

                //Delete box
                string requestData = JsonConvert.SerializeObject(Data);

                bool response = await NovaAPI.APIBoxes.GetValues("6", DataConfig.LocalAPI, requestData);

                if (response)
                {
                    NovaAPI.APIBoxes.boxes.Remove(NovaAPI.APIBoxes.boxes.Find(x => x.id == Control.Tag.ToString()));
                    BoxDataGrid.Items.Refresh();
                }
                else
                {
                    MessageBox.Show($"Error al eliminarel punto de venta, {Environment.NewLine}{NovaAPI.APIBoxes.Message}");
                }
            }
        }
Beispiel #2
0
 private void BranchCB_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (BoxesTab.IsSelected)
     {
         SelectedBoxIndex = "";
         if (BoxFormGrid.Opacity != 0)
         {
             BoxFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
         }
         try
         {
             LoadBoxes(NovaAPI.APIBranch.branch[BranchCB.SelectedIndex].id);
         }
         catch (Exception) { }
     }
 }
Beispiel #3
0
        //New button logic
        private void NewPointBT_Click(object sender, RoutedEventArgs e)
        {
            //From grid animation
            if (BoxFormGrid.Opacity == 0)
            {
                BoxFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("PopUpGrid"));
                BoxNameTX.Focus();
                SavePointBT.IsEnabled = true;
            }
            else if (BoxNameTX.Text.Length == 0)
            {
                BoxFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                SavePointBT.IsEnabled = false;
            }

            //Clear box values
            if (BoxNameTX.Text.Length > 0)
            {
                BoxNameTX.Clear();
                SelectedBoxIndex = "";
            }
        }
Beispiel #4
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            //Get button control
            Button Control = (Button)sender;

            var Box = NovaAPI.APIBoxes.boxes.Find(x => x.id == Control.Tag.ToString());

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

            //Set box information to controls
            BoxNameTX.Text     = Box.name;
            StatusCB.IsChecked = Box.status == "1" ? true : false;


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

            //Focus editable rol
            BoxNameTX.Focus();
            SavePointBT.IsEnabled = true;
        }
Beispiel #5
0
        //Save box point data
        private async void SavePointBT_Click(object sender, RoutedEventArgs e)
        {
            NewPointBT.Focus();

            if (BoxNameTX.Text.Length == 0 || BoxNameTX.Text.Length < 5)
            {
                MessageBox.Show("El nombre del punto de venta no puede ir en blanco o ser inferior a 5 caracteres");
                BoxNameTX.Focus();
                return;
            }

            //Get/Set box parameters
            var Data = new NovaAPI.APIBoxes.BoxesData();

            Data.id        = SelectedBoxIndex;
            Data.name      = BoxNameTX.Text;
            Data.branch_id = NovaAPI.APIBranch.branch[BranchCB.SelectedIndex].id;
            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.APIBoxes.GetValues("8", DataConfig.LocalAPI, requestData);
            }
            else
            {
                response = await NovaAPI.APIBoxes.GetValues("7", DataConfig.LocalAPI, requestData);
            }

            //Request response
            if (response)
            {
                if (Data.id.Length > 0)
                {
                    //On supplier modified
                    var Boxdata = NovaAPI.APIBoxes.boxes.Find(x => x.id == Data.id);
                    Boxdata.name   = Data.name;
                    Boxdata.status = Data.status;
                    BoxDataGrid.Items.Refresh();
                    BoxFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    BoxNameTX.Clear();
                }
                else
                {
                    //On new supplier created response
                    var Boxdata = new NovaAPI.APIBoxes.BoxesClass();
                    Boxdata.name   = Data.name;
                    Boxdata.status = Data.status;
                    Boxdata.id     = NovaAPI.APIBoxes.LastID;

                    BoxFormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    BoxNameTX.Clear();

                    NovaAPI.APIBoxes.boxes.Add(Boxdata);

                    //Reload box data
                    LoadBoxes(NovaAPI.APIBranch.branch[BranchCB.SelectedIndex].id);
                }
            }
            else
            {
                MessageBox.Show($"Error al crear el punto de venta, INFO: {Environment.NewLine}{NovaAPI.APIBoxes.Message}");
            }
            SavePointBT.IsEnabled = false;
            SelectedBoxIndex      = "";
        }