コード例 #1
0
ファイル: frmVendedores.cs プロジェクト: enspdf/EF-CRUD-REP
 private void CargarGrid()
 {
     using (var context = new EntidadesVentas())
     {
         var vendedores = from q in context.Vendedor select q;
         dgVendedores.DataSource = vendedores.ToList();
         dgVendedores.Refresh();
     }
 }
コード例 #2
0
ファイル: frmClientes.cs プロジェクト: enspdf/EF-CRUD-REP
 public void CargarGrid()
 {
     using (var context = new EntidadesVentas())
     {
         var clientes = from q in context.Cliente select q;
         dgClientes.DataSource = clientes.ToList();
         dgClientes.Refresh();
     }
 }
コード例 #3
0
ファイル: frmClientes.cs プロジェクト: enspdf/EF-CRUD-REP
 private void btnModificar_Click(object sender, EventArgs e)
 {
     using (var context = new EntidadesVentas())
     {
         int cod = Convert.ToInt32(txtCodigoCliente.Text);
         Cliente oCliente = context.Cliente.Single(c => c.CodCliente == cod);
         oCliente.NombreCompleto = txtNombreCliente.Text;
         context.SaveChanges();
         MessageBox.Show("El cliente " + txtCodigoCliente.Text + " ha sido actualizado correctamente");
         CargarGrid();
         Limpiar();
     }
 }
コード例 #4
0
ファイル: frmVendedores.cs プロジェクト: enspdf/EF-CRUD-REP
 private void btnModificar_Click(object sender, EventArgs e)
 {
     using (var context = new EntidadesVentas())
     {
         int cod = Convert.ToInt32(txtCodigoVendedor.Text);
         Vendedor oVendedor = context.Vendedor.Single(v => v.CodVendedor == cod);
         oVendedor.NombreCompleto = txtNombreVendedor.Text;
         context.SaveChanges();
         MessageBox.Show("El vendedor " + txtCodigoVendedor.Text + " ha sido actualizado correctamente");
         CargarGrid();
         Limpiar();
     }
 }
コード例 #5
0
        //  metodo de inserción de la tabla ventas
        public bool insertarVentas(EntidadesVentas entidad)
        {
            tblVentas tabla = new tblVentas();

            tabla.fecha      = entidad.fecha;
            tabla.idCliente  = entidad.idCliente;
            tabla.idEmpleado = entidad.idEmpleado;
            tabla.cantidad   = entidad.cantidad;
            tabla.precio     = entidad.precio;
            tabla.iva        = entidad.iva;
            tabla.total      = entidad.total;
            return(metodoVenta.insertarVenta(tabla));
        }
コード例 #6
0
ファイル: frmConsulta.cs プロジェクト: enspdf/EF-CRUD-REP
        private void CargarDatos()
        {
            using (var context = new EntidadesVentas())
            {
                cbCliente.DataSource = (from q in context.Cliente select q).ToList();
                cbCliente.DisplayMember = "NombreCompleto";
                cbCliente.ValueMember = "CodCliente";

                cbProducto.DataSource = (from q in context.Producto select q).ToList();
                cbProducto.DisplayMember = "NomProducto";
                cbProducto.ValueMember = "CodProducto";
            }
        }
コード例 #7
0
ファイル: frmClientes.cs プロジェクト: enspdf/EF-CRUD-REP
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            using (var context = new EntidadesVentas())
            {
                Cliente oCliente = new Cliente
                {
                    CodCliente = Convert.ToInt32(txtCodigoCliente.Text),
                    NombreCompleto = txtNombreCliente.Text
                };

                context.Cliente.Add(oCliente);
                context.SaveChanges();
                MessageBox.Show("El cliente " + txtNombreCliente.Text + " ha sido registrado satisfatoriamente");
                CargarGrid();
                Limpiar();
            }
        }
コード例 #8
0
ファイル: frmVendedores.cs プロジェクト: enspdf/EF-CRUD-REP
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            using (var context = new EntidadesVentas())
            {
                Vendedor oVendedor = new Vendedor
                {
                    CodVendedor = Convert.ToInt32(txtCodigoVendedor.Text),
                    NombreCompleto = txtNombreVendedor.Text
                };

                context.Vendedor.Add(oVendedor);
                context.SaveChanges();
                MessageBox.Show("El vendedor " + txtNombreVendedor.Text + " ha sido registrado correctamente");
                CargarGrid();
                Limpiar();
            }
        }
コード例 #9
0
ファイル: frmConsulta.cs プロジェクト: enspdf/EF-CRUD-REP
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            using (var context = new EntidadesVentas())
            {
                var lista = (from det in context.DetalleFactura
                             where
                                 det.Factura.CodCliente == ((Cliente)cbCliente.SelectedItem).CodCliente
                                 && det.CodProducto == ((Producto)cbProducto.SelectedItem).CodProducto
                             select new
                             {
                                 Cliente = det.Factura.Cliente.NombreCompleto,
                                 Producto = det.Producto.NomProducto,
                                 Factura = det.Factura.CodFactura
                             }).ToList();

                dgConsulta.DataSource = null;
                dgConsulta.DataSource = lista;
                dgConsulta.Refresh();
            }
        }
コード例 #10
0
ファイル: frmFacturar.cs プロジェクト: enspdf/EF-CRUD-REP
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            using (var context = new EntidadesVentas())
            {

                Factura oFactura = new Factura()
                {
                    CodVendedor = Convert.ToInt32(cbVendedor.SelectedValue),
                    CodCliente = Convert.ToInt32(cbCliente.SelectedValue),
                    VlrTotal = Convert.ToInt32(txtTotal.Text)
                };

                foreach (var item in ListaDetalles)
                {
                    item.CodFactura = oFactura.CodFactura;
                    oFactura.DetalleFactura.Add(item);
                }

                context.Factura.Add(oFactura);

                context.SaveChanges();
                MessageBox.Show("Factura guardada correctamente");
            }
        }