Ejemplo n.º 1
0
        public void Listar(ref DataGrid iGrillaProductos)
        {
            try
            {
                List<Entity.Almacen.Producto> listarProductos
                       = new Core.Almacen.Producto(this.conexion)
                       .Listar();

                this.SetItemsSourceGrilla(ref iGrillaProductos, listarProductos);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public void BuscarPorDescripcionYEstado(ref DataGrid iGrillaProductos, bool iEstado, string iDescripcion)
        {
            try
            {
                List<Entity.Almacen.Producto> listarProductos
                       = new Core.Almacen.Producto(this.conexion)
                       .BuscarPorDescripcionYEstado(iEstado, iDescripcion);

                this.SetItemsSourceGrilla(ref iGrillaProductos, listarProductos);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        private void Registrar()
        {
            try
            {
                if (this.producto == null)
                    this.producto = new Producto(this.conexion);

                this.producto.Descripcion = this.txtDescripcion.Text;
                this.producto.Estado = this.chkEstado.IsChecked.Value;
                this.producto.StockLimitado = this.chkStockLimitado.IsChecked.Value;
                this.producto.PrecioVenta = Funcion.ConvertTo<decimal>(this.txtPrecioVenta.Text, 0.00);
                this.producto.Stock = Funcion.ConvertTo<decimal>(this.txtStock.Text, 0.00);
                this.producto.Categoria = new Categoria();
                this.producto.Unidad = new Unidad(this.conexion);
                this.producto.Categoria.Id = Funcion.ConvertTo<int>(this.cboCategoria.SelectedValue, 0);
                this.producto.Unidad.Id = Funcion.ConvertTo<int>(this.cboUnidad.SelectedValue, 0);
                this.producto.Comision = Funcion.ConvertTo<decimal>(this.txbComision.Text, 0.00);

                if (this.producto.Categoria.Id <= 0)
                    throw new ExepcionSHomies("Seleccione categoria del producto.");
                if (string.IsNullOrEmpty(this.producto.Descripcion))
                    throw new ExepcionSHomies("Ingrese descripción para el producto.");
                if (this.producto.PrecioVenta <= 0)
                    throw new ExepcionSHomies("Precio de venta debe ser mayor a cero.");
                if (this.producto.Unidad.Id <= 0)
                    throw new ExepcionSHomies("Seleccione unidad minima del producto.");
                if (this.producto.StockLimitado && this.producto.Stock <= 0)
                    throw new ExepcionSHomies("Stock debe ser mayor a cero.");

                this.producto.Conexion.BeginTransaction();
                if (this.producto.Registrar())
                {
                    this.txbId.Text = this.producto.Id.ToString();
                    this.grbRegistrar.IsEnabled = false;
                    this.btnGrabar.IsEnabled = false;
                    this.btnCancelar.IsEnabled = false;
                    this.btnModificar.IsEnabled = true;

                    this.producto.Conexion.Commit();

                    MessageBox.Show("Producto guardado con exito");

                    this.ListarProductos();
                }
            }
            catch (ExepcionSHomies sh)
            {
                MessageBox.Show(sh.Message);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                this.producto.Conexion.RoolBack();
            }
        }
Ejemplo n.º 4
0
 public AdministraProducto(SHomies.Conexion.IConexion iConexion)
 {
     InitializeComponent();
     producto = new Core.Almacen.Producto(iConexion);
     conexion = iConexion;
 }