コード例 #1
0
ファイル: Enca_FacturaLN.cs プロジェクト: falfaro12/Proyecto
        public static Enca_Factura obtenerEnca_Factura(int id)
        {
            EcomonedasContexto db   = new EcomonedasContexto();
            Enca_Factura       enca = db.Enca_Factura.
                                      Where(p => p.Id_Enca == id).
                                      First <Enca_Factura>();

            return(enca);
        }
コード例 #2
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            string correo = ddlClientes.SelectedValue;

            Session["encabezadoOrden"] = null;
            Enca_Factura enca = new Enca_Factura();

            enca.Usuario = UsuarioLN.obtenerUsuario(ddlClientes.SelectedValue);
            Session["encabezadoOrden"] = enca;
            ddlClientes.SelectedValue  = enca.Usuario.Id_Usuario;
        }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         llenarListaCarrito();
         llenarComboClientes();
         if (Session["encabezadoOrden"] != null)
         {
             Enca_Factura enca = (Enca_Factura)Session["encabezadoOrden"];
             ddlClientes.SelectedValue = enca.Usuario.Id_Usuario;
         }
     }
 }
コード例 #4
0
        public static bool registrarOrden(
            string idCliente, int idCentro, List <CarritoCanjes> carritoItems
            )
        {
            EcomonedasContexto db = new EcomonedasContexto();
            //Orden
            var miOrden = new Enca_Factura();

            miOrden.Fecha      = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            miOrden.Id_Usuario = idCliente;
            miOrden.Id_Centro  = idCentro;
            //Calcular total
            decimal calculoTotal = carritoItems.Sum(x => x.subTotal);

            miOrden.Total = calculoTotal;

            //Agregar orden a la BD
            db.Enca_Factura.Add(miOrden);
            db.SaveChanges();

            //Detalle orden
            for (int i = 0; i < carritoItems.Count; i++)
            {
                var miDetalle = new Detall_Factura();
                miDetalle.Id_Enca     = miOrden.Id_Enca;
                miDetalle.Id_Material = carritoItems[i].Id_Material;
                miDetalle.Cantidad    = carritoItems[i].cantidad;
                miDetalle.SubTotal    = carritoItems[i].precioMaterial;

                //Agregar orden detalle a la BD
                db.Detall_Factura.Add(miDetalle);
                db.SaveChanges();
            }

            return(true);
        }