Exemplo n.º 1
0
        private void dgvArticles_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //EDITAR STORE
            if (e.ColumnIndex == 0)
            {
                int     idEdit              = Convert.ToInt32(dgvArticles.Rows[e.RowIndex].Cells["id"].Value.ToString());
                string  nameArticles        = dgvArticles.Rows[e.RowIndex].Cells["name"].Value.ToString();
                string  descriptionArticles = dgvArticles.Rows[e.RowIndex].Cells["description"].Value.ToString();
                decimal priceArticles       = Convert.ToDecimal(dgvArticles.Rows[e.RowIndex].Cells["price"].Value.ToString());
                int     totalShelfArticles  = Convert.ToInt32(dgvArticles.Rows[e.RowIndex].Cells["total_in_shelf"].Value.ToString());
                int     totalVaultArticles  = Convert.ToInt32(dgvArticles.Rows[e.RowIndex].Cells["total_in_vault"].Value.ToString());
                int     storeIdArticles     = Convert.ToInt32(dgvArticles.Rows[e.RowIndex].Cells["store_id"].Value.ToString());


                var selectTienda = (from a in listStoresGlobal
                                    where a["id"].ToString() == storeIdArticles.ToString()
                                    select new
                {
                    id = a["id"],
                    name = a["name"],
                    address = a["address"]
                }).FirstOrDefault();
                //AGREGAR STORE
                AgregarEditarArticles agregarArticles = new AgregarEditarArticles(AgregarEditarArticles.Tipo.Edit, nameArticles,
                                                                                  descriptionArticles, priceArticles, totalShelfArticles,
                                                                                  totalVaultArticles, selectTienda, listStores);
                agregarArticles.Text = "Editar Articulo";
                agregarArticles.ShowDialog();

                if (agregarArticles.esGuardar)
                {
                    var article = (dynamic) new JObject();
                    article.id             = idEdit;
                    article.name           = agregarArticles.nameArticles;
                    article.description    = agregarArticles.descriptionArticles;
                    article.price          = agregarArticles.priceArticles;
                    article.total_in_shelf = agregarArticles.totalShelfArticles;
                    article.total_in_vault = agregarArticles.totalVaultArticles;
                    article.store_id       = agregarArticles.idStore;

                    EditArticles(idEdit, article);
                }
            }
            //ELIMINAR STORE
            else if (e.ColumnIndex == 1)
            {
                DialogResult respuestaEliminar = MessageBox.Show("¿Estas seguro de que quieres eliminar el Articulo?", "Eliminar Articulo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (respuestaEliminar.ToString().ToUpper() == "YES")
                {
                    int idDelete = Convert.ToInt32(dgvArticles.Rows[e.RowIndex].Cells["id"].Value.ToString());

                    DeleteArticles(idDelete);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// METODOS ARTICULOS
        /// </summary>
        #region Metodos_Articulos
        private void btnAgregarArticulo_Click(object sender, EventArgs e)
        {
            //AGREGAR STORE
            AgregarEditarArticles agregarArticles = new AgregarEditarArticles(AgregarEditarArticles.Tipo.Add, "", "", 0, 0, 0, 0, listStores);

            agregarArticles.Text = "Agregar Articulo";
            agregarArticles.ShowDialog();

            if (agregarArticles.esGuardar)
            {
                var article = (dynamic) new JObject();
                article.name           = agregarArticles.nameArticles;
                article.description    = agregarArticles.descriptionArticles;
                article.price          = agregarArticles.priceArticles;
                article.total_in_shelf = agregarArticles.totalShelfArticles;
                article.total_in_vault = agregarArticles.totalVaultArticles;
                article.store_id       = agregarArticles.idStore;

                AddArticles(article);
            }
        }