Exemplo n.º 1
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            //try
            //{
            using (Datos.AlmacenEntities modelo = new Datos.AlmacenEntities())
            {
                DateTime fe  = DateTime.Parse(txtfecha.Value.ToString());
                Factura  fac = new Factura()
                {
                    numSerie   = txtserie.Value,
                    numFactura = Convert.ToInt32(txtnumfactura.Value),
                    nit        = txtnit.Value,
                    fecha      = fe,
                    total      = Convert.ToDecimal(txttotal.Value)
                };
                modelo.Factura.Add(fac);
                modelo.SaveChanges();

                foreach (DetalleFactura item in detalle)
                {
                    DetalleFactura detail = new DetalleFactura()
                    {
                        numSerie    = item.numSerie,
                        numFactura  = item.numFactura,
                        codProducto = item.codProducto,
                        cantidad    = item.cantidad,
                        precio      = item.precio,
                        subtotal    = Convert.ToDecimal(txttotal.Value),
                        nombre      = item.nombre
                    };
                    modelo.DetalleFactura.Add(detail);
                    modelo.SaveChanges();

                    DetalleRegistro deta = new DetalleRegistro()
                    {
                        fecha       = fe,
                        codProducto = item.codProducto,
                        tipo        = 2,
                        cantidad    = item.cantidad,
                        idBodega    = 1
                    };
                }
                modelo.FN_MostraFactura(Convert.ToInt32(txtnumfactura.Value));
            }
            detalle = new List <DetalleFactura>();
            //Response.Redirect("WebFacturaNueva.aspx");
        }
Exemplo n.º 2
0
 private void eliminar(string idProducto)
 {
     using (Datos.AlmacenEntities modelo = new Datos.AlmacenEntities())
     {
         Producto cat = (from q in modelo.Producto
                         where q.sku == idProducto
                         select q).First();
         modelo.Producto.Remove(cat);
         modelo.SaveChanges();
     }
 }
 private void eliminar(string idcliente)
 {
     using (Datos.AlmacenEntities modelo = new Datos.AlmacenEntities())
     {
         Cliente cat = (from q in modelo.Cliente
                        where q.nit == idcliente
                        select q).First();
         modelo.Cliente.Remove(cat);
         modelo.SaveChanges();
     }
 }