Example #1
0
        private void CargaCategorias()
        {
            DataSet1TableAdapters.SP_tabla_categoriaTableAdapter categta = new Bar.DataSet1TableAdapters.SP_tabla_categoriaTableAdapter();
            DataTable catdt = categta.GetData("S", null, "", null, null);

            dibujabottonCategoria(catdt);
        }
Example #2
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvCategoria.SelectedRows.Count > 0)
                {
                    idCategoria = (int)dgvCategoria.SelectedRows[0].Cells[0].Value;
                    nombre      = dgvCategoria.SelectedRows[0].Cells[1].Value.ToString();
                }
                else
                {
                    return;
                }

                DialogResult response = MessageBox.Show(string.Format("¿Está seguro de eliminar la categoria {0} ?", nombre), "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (response == DialogResult.Yes)
                {
                    DataSet1TableAdapters.SP_tabla_categoriaTableAdapter cta = new Bar.DataSet1TableAdapters.SP_tabla_categoriaTableAdapter();
                    cta.GetData("D", idCategoria, "", null, null);
                }
                cargarCategorias();
                limpiarCampos();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Example #3
0
        private void cargarCategorias()
        {
            DataSet1TableAdapters.SP_tabla_categoriaTableAdapter categta = new Bar.DataSet1TableAdapters.SP_tabla_categoriaTableAdapter();
            DataTable catdt = categta.GetData("S", null, "", null, null);

            dgvCategoria.DataSource = catdt;
            dgvCategoria.Refresh();
        }
Example #4
0
        private void cargarCategorias()
        {
            DataSet1TableAdapters.SP_tabla_categoriaTableAdapter categta = new Bar.DataSet1TableAdapters.SP_tabla_categoriaTableAdapter();
            DataTable catdt = categta.GetData("S", null, "", null, null);

            cmbCategoria.DataSource    = catdt;
            cmbCategoria.DisplayMember = "nombre";
            cmbCategoria.ValueMember   = "idCategoria";
            cmbCategoria.Refresh();
        }
Example #5
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            if (btnActualizar.Text == "Guardar")
            {
                string valida = validate();
                if (valida == "OK")
                {
                    try
                    {
                        DataSet1TableAdapters.SP_tabla_categoriaTableAdapter cta = new Bar.DataSet1TableAdapters.SP_tabla_categoriaTableAdapter();

                        cta.GetData("U", idCategoria, nombre, aplicaInventario, aplicaVenta);
                        cargarCategorias();
                        idCategoria        = 0;
                        btnActualizar.Text = "Actualizar";
                        btnAgregar.Enabled = true;
                        limpiarCampos();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show(valida, "Valida", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                try
                {
                    if (dgvCategoria.SelectedRows.Count > 0)
                    {
                        idCategoria = (int)dgvCategoria.SelectedRows[0].Cells[0].Value;
                    }
                    else
                    {
                        return;
                    }
                    btnAgregar.Enabled = false;
                    //btnActualizar.Enabled = true;
                    btnActualizar.Text = "Guardar";
                    DataSet1TableAdapters.SP_tabla_categoriaTableAdapter cta = new Bar.DataSet1TableAdapters.SP_tabla_categoriaTableAdapter();
                    DataTable cdt = cta.GetData("F", idCategoria, "", null, null);
                    if (cdt.Rows.Count == 1)
                    {
                        txtNombre.Text = cdt.Rows[0]["nombre"].ToString();
                        chbCuentaInventario.Checked = bool.Parse(cdt.Rows[0]["cuentaInventario"].ToString());
                        chbCuentaVenta.Checked      = bool.Parse(cdt.Rows[0]["cuentaVenta"].ToString());
                    }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
            }
        }
Example #6
0
        private int recuperaidCategoria(string nombre)
        {
            DataSet1TableAdapters.SP_tabla_categoriaTableAdapter categta = new Bar.DataSet1TableAdapters.SP_tabla_categoriaTableAdapter();
            DataTable catdt = categta.GetData("S", null, "", null, null);

            for (int i = 0; i <= catdt.Rows.Count - 1;)
            {
                if (catdt.Rows[i][1].ToString() == nombre)
                {
                    return(valorc = int.Parse(catdt.Rows[i][0].ToString()));
                }
                i++;
            }
            return(0);
        }
Example #7
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            string valida = validate();

            if (valida == "OK")
            {
                try
                {
                    DataSet1TableAdapters.SP_tabla_categoriaTableAdapter cta = new Bar.DataSet1TableAdapters.SP_tabla_categoriaTableAdapter();
                    cta.GetData("I", null, nombre, aplicaInventario, aplicaVenta);
                    cargarCategorias();
                    limpiarCampos();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show(valida, "Valida", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }