Exemplo n.º 1
0
        private void loadArticles()
        {
            List <BEArticle> lista = null;

            BEStore store   = cmbFindStore.SelectedItem as BEStore;
            short?  idStore = null;

            if (store != null && store.id > 0)
            {
                idStore = store.id;
            }

            BERespuesta res = articleApiConsumer.GetArticles(idStore);

            if (!res.success)
            {
                MessageBox.Show(string.Format(Recursos.Rscresx.mensajeEtiquetaOcurrioUnError, string.Empty),
                                Recursos.Rscresx.mensajeEtiquetaAviso, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
            lista = JsonConvert.DeserializeObject <List <BEArticle> >(res.articles.ToString());

            dgArticles.DataSource = lista;
        }
Exemplo n.º 2
0
        private bool ValidateData()
        {
            bool    res          = true;
            decimal price        = 0;
            int     totalInShelf = 0;

            decimal.TryParse(txtPrice.Text, out price);
            BEStore store = cmbStore.SelectedItem as BEStore;

            int.TryParse(txtTotalInShelf.Text, out totalInShelf);

            if (string.IsNullOrEmpty(txtName.Text))
            {
                MessageBox.Show("Es necesario suministrar el nombre del articulo.",
                                Recursos.Rscresx.mensajeEtiquetaAviso, MessageBoxButtons.OK, MessageBoxIcon.Error);

                txtName.Focus();

                res = false;
            }
            else if (string.IsNullOrEmpty(txtDescription.Text))
            {
                MessageBox.Show("Es necesario suministrar la descripción del articulo.",
                                Recursos.Rscresx.mensajeEtiquetaAviso, MessageBoxButtons.OK, MessageBoxIcon.Error);

                txtDescription.Focus();
                res = false;
            }
            else if (price <= 0)
            {
                MessageBox.Show("Es necesario suministrar el precio del articulo.",
                                Recursos.Rscresx.mensajeEtiquetaAviso, MessageBoxButtons.OK, MessageBoxIcon.Error);

                txtPrice.Focus();
                res = false;
            }
            else if (totalInShelf <= 0)
            {
                MessageBox.Show("Es necesario suministrar el total en boveda del articulo.",
                                Recursos.Rscresx.mensajeEtiquetaAviso, MessageBoxButtons.OK, MessageBoxIcon.Error);

                txtTotalInShelf.Focus();
                res = false;
            }
            else if (store == null || store.id <= 0)
            {
                MessageBox.Show("Es necesario seleccionar la tienda a la que pertenece el articulo.",
                                Recursos.Rscresx.mensajeEtiquetaAviso, MessageBoxButtons.OK, MessageBoxIcon.Error);

                cmbStore.Focus();
                res = false;
            }

            return(res);
        }
Exemplo n.º 3
0
        private void saveArticle()
        {
            if (ValidateData())
            {
                BEStore store = cmbStore.SelectedItem as BEStore;

                string  name         = txtName.Text;
                string  description  = txtDescription.Text;
                int     totalInVault = int.Parse(txtTotalInVault.Text);
                int     totalInShelf = int.Parse(txtTotalInShelf.Text);
                short   storeId      = store.id;
                decimal price        = decimal.Parse(txtPrice.Text);

                BERespuesta res = articleApiConsumer.AddArticle(name, description, price, totalInShelf, totalInVault,
                                                                storeId);

                if (res.success)
                {
                    MessageBox.Show("Se ha guardado el articulo de manera satisfactoria. Presione OK", Recursos.Rscresx.mensajeEtiquetaAviso,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);

                    cleanControls();
                    enabledControls(false);

                    btnNewSave.Text = Recursos.Rscresx.mensajeEtiquetaNuevo;
                    btnClose.Text   = Recursos.Rscresx.mensajeEtiquetaCerrar;

                    tipo = TipoComandoEnum.Ninguno;

                    loadArticles();
                }
                else
                {
                    MessageBox.Show(Recursos.Rscresx.mensajeEtiquetaErrorArticuloGuardar, Recursos.Rscresx.mensajeEtiquetaAviso,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }