Example #1
0
        public static int Actualizar(Categoria categoria)
        {
            SqlCommand sql = new SqlCommand("usp_Data_FCategoria_Actualizar",conexion.ObtenerConexion());
            sql.CommandType = CommandType.StoredProcedure;

            sql.Parameters.AddWithValue("@Id",categoria.Id);
            sql.Parameters.AddWithValue("@Descripcion", categoria.Descripcion);

            int resul = sql.ExecuteNonQuery();
            return Convert.ToInt32(resul > 0);
        }
Example #2
0
        public Articulo(int id,string descArt,double precioVenta,int existencia,
            string nombre,Categoria categoria,DateTime fechaV,int minimo,double precioCompra,Proveedor proveedor)
        {
            Id = id;
            Categoria1 = categoria;
            DescArt = descArt;
            PrecioVenta = precioVenta;
            Existencia = existencia;
            Nombre = nombre;
            FechaVencimiento = fechaV;

            Minimo = minimo;
            PrecioCompra = precioCompra;
            nProveedor = proveedor;
        }
Example #3
0
        public static bool Agregar(Categoria categoria)
        {
            SqlCommand sql = new SqlCommand("usp_Data_FCategoria_Insert",conexion.ObtenerConexion());
            sql.CommandType= CommandType.StoredProcedure;

            sql.Parameters.Add("@Descripcion", SqlDbType.VarChar, 0).Value = categoria.Descripcion;

            try
            {
                int resultado = sql.ExecuteNonQuery();
                return resultado > 0;
            }
            catch (Exception)
            {
                return false;

            }
        }
Example #4
0
        public static int Eliminar(Categoria categoria)
        {
            SqlCommand sql = new SqlCommand("usp_Data_FCategoria_Borrar");
            sql.CommandType=CommandType.StoredProcedure;

            sql.Parameters.AddWithValue("@Id", categoria.Id);
            int resul = sql.ExecuteNonQuery();
            return Convert.ToInt32(resul > 0);

            //try
            //{
            //    int resultado = sql.ExecuteNonQuery();
            //    return resultado > 0;
            //}
            //catch (Exception)
            //{
            //    return false;

            //}
            //return Convert.ToInt32(sql);
        }
Example #5
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("¿Realmente desea eliminar las Categorias seleccionadas?", "Eliminacion de Categorias,", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    foreach (DataGridViewRow row in dgvCategoria.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells["Eliminar"].Value))
                        {
                            Categoria categoria = new Categoria();
                            categoria.Id = Convert.ToInt32(row.Cells["Id"].Value);
                            if (Fcategoria.Eliminar(categoria) != 1)
                            {
                                MessageBox.Show("Las Categorias no pudieron ser eliminadas! ", "Eliminacion de Categorias", MessageBoxButtons.OK, MessageBoxIcon
                                    .Warning);
                                frmCategoria_Load(null, null);
                            }
                        }
                    }
                    frmCategoria_Load(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);

            }
        }
Example #6
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                string sResultado = ValidarDatos();
                if (sResultado=="")
                {
                    if (txtId.Text=="")
                    {
                        Categoria categoria = new Categoria();
                        categoria.Descripcion = txtDescripcion.Text;
                        if (Fcategoria.Agregar(categoria))
                        {
                            MessageBox.Show("Categoria Guardada Exitosamente!");
                            frmCategoria_Load(null,null);
                        }
                    }
                    else
                    {
                        Categoria categoria=new Categoria();
                        categoria.Id = Convert.ToInt32(txtId.Text);
                        categoria.Descripcion = txtDescripcion.Text;
                        if (Fcategoria.Actualizar(categoria)==1)
                        {
                            MessageBox.Show("Datos Actualizados Correctamente!");
                            frmCategoria_Load(null,null);
                        }

                    }
                }
                else
                {
                    MessageBox.Show("Faltan Datos! \n" + sResultado);
                }

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Example #7
0
 public Articulo()
 {
     Categoria1 = new Categoria();
     nProveedor = new Proveedor();
 }