Exemplo n.º 1
0
        public void crearInventario(List <producto> produc, inventario inventa, String[] estante, String[] prove)
        {
            using (contextData cdt = new contextData())
            {
                cdt.Configuration.LazyLoadingEnabled = false;

                try
                {
                    //salvar primero el inventario, luego los productos
                    cdt.inventario.Add(inventa);

                    //llenar estante, producto, inventario y proveedor
                    foreach (var productoItem in produc)
                    {
                        detalleFactura df = new detalleFactura();
                        df.idInventario     = inventa.id;
                        df.idProducto       = productoItem.id;
                        df.idProveedor      = int.Parse(prove[0]);
                        df.idEstante        = int.Parse(estante[0]);
                        df.precio           = productoItem.costoUnitario;
                        df.cantidadComprada = productoItem.totalStock;

                        cdt.detalleFactura.Add(df);
                    }

                    cdt.SaveChanges();
                }
                catch (Exception ex)
                {
                    string mensaje = "";
                    Log.Error(ex, System.Reflection.MethodBase.GetCurrentMethod(), ref mensaje);
                    throw;
                }
            }
        }
Exemplo n.º 2
0
        protected void listaDatos_ItemCommand(object source, DataListCommandEventArgs e)
        {
            /*if (e.CommandName == "add")
             * {
             *  int posicion = e.Item.ItemIndex;
             *  idproducto_name.Text = Convert.ToString(lista[posicion].idProducto);
             *
             *  //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(' UNO " + e.CommandArgument.ToString() + "')", true);
             * }*/
            //else

            if (e.CommandName == "add")
            {
                if (contador >= 0)
                {
                    if (contador == 0)
                    {
                        //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert(' UNO " + e.CommandArgument.ToString() + "')", true);
                    }
                    int posicion = e.Item.ItemIndex;
                    detalle = new detalleFactura();
                    numItem++;
                    detalle.numItem     = preferencesPedido.listaDetalle.Count + 1;
                    detalle.idProducto  = lista[posicion].idProducto;
                    detalle.descripcion = lista[posicion].descripcion;
                    detalle.cantidad    = 1;
                    detalle.precio      = lista[posicion].precio;

                    preferencesPedido.listaDetalle.Add(detalle);
                    preferencesPedido.listaDetalleCopia.Add(detalle);
                }
                contador++;
            }
            if (e.CommandName == "fin")
            {
                if (Session["usuario"] == null)
                {
                    Response.Redirect("~/FormLogin.aspx");
                }
                else
                {
                    if (preferencesPedido.listaDetalle.Count > 0)
                    {
                        Response.Redirect("~/FormDocumento.aspx");
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('No hay productos agregados al carrito')", true);
                    }
                }
            }
        }