Esempio n. 1
0
        public ActionResult Create([Bind(Include = "PROVEEDOR,PRODUC,PRECIO,CATEGORIA,PRECIO_MIN,PRECIO_MAX")] PRODUCTOS pRODUCTOS)
        {
            if (ModelState.IsValid)
            {
                db.PRODUCTOS.Add(pRODUCTOS);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pRODUCTOS));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "ID,NOMBRE_PROVEEDOR,TELEFONO,FECHA_VENTA")] DATOS dATOS)
        {
            if (ModelState.IsValid)
            {
                db.DATOS.Add(dATOS);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.NOMBRE_PROVEEDOR = new SelectList(db.PRODUCTOS, "PROVEEDOR", "PRODUC", dATOS.NOMBRE_PROVEEDOR);
            return(View(dATOS));
        }
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (txtApellido.Text != "" && txtContra.Text != "" &&
         txtNombre.Text != "" && txtUsuario.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             try
             {
                 Empleado em  = new Empleado();
                 string   id  = dgvEmpleados.CurrentRow.Cells[0].Value.ToString();
                 int      id2 = int.Parse(id);
                 em = bd.Empleados.Where(verificarId => verificarId.id_empleado == id2).First();
                 bd.Entry(em).State = System.Data.Entity.EntityState.Deleted;
                 bd.SaveChanges();
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Este Empleado esta relacionado a un \n" +
                                 "   registro de venta o de compra,\n" +
                                 "        no se puede eliminar");
             }
         }
     }
     else
     {
         MessageBox.Show("No se aceptan valores Vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (txtApellido.Text != "" && cmbCargos.Text != "" && txtContra.Text != "" &&
         txtNombre.Text != "" && txtUsuario.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             Empleado em = new Empleado();
             em.apellido_empleado = txtApellido.Text;
             em.id_cargo          = int.Parse(cmbCargos.SelectedValue.ToString());
             em.contrasenia       = txtContra.Text;
             em.nombre_empleado   = txtNombre.Text;
             em.usuario           = txtUsuario.Text;
             bd.Empleados.Add(em);
             bd.SaveChanges();
             listaCargos();
         }
     }
     else
     {
         MessageBox.Show("No se aceptan valores Vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }
Esempio n. 5
0
 private void btnModificar_Click(object sender, EventArgs e)
 {
     if (txtDireccion.Text != "" && txtNombre.Text != "" && txtTelefono.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             Proveedore pro = new Proveedore();
             string     id  = dgvProveedores.CurrentRow.Cells[0].Value.ToString();
             int        id2 = int.Parse(id);
             pro = bd.Proveedores.Where(verificarId => verificarId.id_proveedor == id2).First();
             pro.nombre_proveedor = txtNombre.Text;
             pro.telefono         = txtTelefono.Text;
             pro.direccion        = txtDireccion.Text;
             bd.Entry(pro).State  = System.Data.Entity.EntityState.Modified;
             bd.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("No se pueden guardar \n" +
                         "valores nulos");
     }
     limpiar();
     bloqueo();
     cargar();
 }
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (txtCantidad.Text != "" && txtNombre.Text != "" && txtCosto.Text != "" && txtVenta.Text != "" &&
         cmbProveedor.Text != "" && cmbCategoria.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             Producto pro = new Producto();
             pro.id_categoria    = int.Parse(cmbCategoria.SelectedValue.ToString());
             pro.id_proveedor    = int.Parse(cmbProveedor.SelectedValue.ToString());
             pro.nombre_producto = txtNombre.Text;
             pro.cantidad        = int.Parse(txtCantidad.Text);
             pro.costo           = decimal.Parse(txtCosto.Text);
             pro.precio_venta    = decimal.Parse(txtVenta.Text);
             bd.Productos.Add(pro);
             bd.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("No se aceptan valores vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (txtApellido.Text != "" && txtDireccion.Text != "" && txtDui.Text != "" &&
         txtNit.Text != "" && txtNombre.Text != "" && txtNrc.Text != "" && txtTelefono.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             try
             {
                 Cliente cli = new Cliente();
                 string  id  = dgvClientes.CurrentRow.Cells[0].Value.ToString();
                 int     id2 = int.Parse(id);
                 cli = bd.Clientes.Where(verificarId => verificarId.id_cliente == id2).First();
                 bd.Entry(cli).State = System.Data.Entity.EntityState.Deleted;
                 bd.SaveChanges();
             }
             catch (Exception ex)
             {
                 MessageBox.Show("  Este Cliente esta relacionado a un \n" +
                                 "registro de venta, no se puede eliminar");
             }
         }
     }
     else
     {
         MessageBox.Show("No se pueden eliminar \n" +
                         "valores vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (txtApellido.Text != "" && txtDireccion.Text != "" && txtDui.Text != "" &&
                txtNit.Text != "" && txtNombre.Text != "" && txtNrc.Text != "" && txtTelefono.Text != "")
            {
                using (VENTASEntities bd = new VENTASEntities())
                {
                    Cliente cli = new Cliente();
                    string  id  = dgvClientes.CurrentRow.Cells[0].Value.ToString();
                    int     id2 = int.Parse(id);
                    cli = bd.Clientes.Where(verificarId => verificarId.id_cliente == id2).First();
                    cli.apellido_cliente = txtApellido.Text;
                    cli.direccion        = txtDireccion.Text;
                    cli.dui = txtDui.Text;

                    cli.nit             = txtNit.Text;
                    cli.nombre_cliente  = txtNombre.Text;
                    cli.nrc             = txtNrc.Text;
                    cli.telefono        = txtTelefono.Text;
                    bd.Entry(cli).State = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                }
            }
            else
            {
                MessageBox.Show("No se aceptan valores vacios");
            }

            limpiar();
            bloqueo();
            cargar();
        }
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (txtApellido.Text != "" && txtDireccion.Text != "" && txtDui.Text != "" &&
         txtNit.Text != "" && txtNombre.Text != "" && txtNrc.Text != "" && txtTelefono.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             Cliente cli = new Cliente();
             cli.apellido_cliente = txtApellido.Text;
             cli.nombre_cliente   = txtNombre.Text;
             cli.direccion        = txtDireccion.Text;
             cli.telefono         = txtTelefono.Text;
             cli.dui = txtDui.Text;
             cli.nit = txtNit.Text;
             cli.nrc = txtNrc.Text;
             bd.Clientes.Add(cli);
             bd.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("No se pueden guardar \n" +
                         "valores nulos");
     }
     limpiar();
     bloqueo();
     cargar();
 }
 private void btnModificar_Click(object sender, EventArgs e)
 {
     if (txtApellido.Text != "" && cmbCargos.Text != "" && txtContra.Text != "" &&
         txtNombre.Text != "" && txtUsuario.Text != "")
     {
         if (cmbCargos.Text != "")
         {
             using (VENTASEntities bd = new VENTASEntities())
             {
                 Empleado em  = new Empleado();
                 string   id  = dgvEmpleados.CurrentRow.Cells[0].Value.ToString();
                 int      id2 = int.Parse(id);
                 em = bd.Empleados.Where(verificarId => verificarId.id_empleado == id2).First();
                 em.apellido_empleado = txtApellido.Text;
                 em.id_cargo          = int.Parse(cmbCargos.SelectedValue.ToString());
                 em.contrasenia       = txtContra.Text;
                 em.nombre_empleado   = txtNombre.Text;
                 em.usuario           = txtUsuario.Text;
                 bd.Entry(em).State   = System.Data.Entity.EntityState.Modified;
                 bd.SaveChanges();
                 listaCargos();
             }
         }
         else if (cmbCargos.Text == "")
         {
             using (VENTASEntities bd = new VENTASEntities())
             {
                 Empleado em  = new Empleado();
                 string   id  = dgvEmpleados.CurrentRow.Cells[0].Value.ToString();
                 int      id2 = int.Parse(id);
                 em = bd.Empleados.Where(verificarId => verificarId.id_empleado == id2).First();
                 em.apellido_empleado = txtApellido.Text;
                 em.contrasenia       = txtContra.Text;
                 em.nombre_empleado   = txtNombre.Text;
                 em.usuario           = txtUsuario.Text;
                 bd.Entry(em).State   = System.Data.Entity.EntityState.Modified;
                 bd.SaveChanges();
                 listaCargos();
             }
         }
     }
     else
     {
         MessageBox.Show("No se aceptan valores Vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }
Esempio n. 11
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (txtNombre.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             Categoria ca = new Categoria();
             ca.nombre_categoria = txtNombre.Text;
             bd.Categorias.Add(ca);
             bd.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("No se aceptan valores vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }
Esempio n. 12
0
 private void btnGuardar_Click_1(object sender, EventArgs e)
 {
     if (txtNombre.Text != "" && txtCargo.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             Cargo ca = new Cargo();
             ca.nombre_cargo = txtNombre.Text;
             ca.sueldo       = decimal.Parse(txtCargo.Text);
             bd.Cargos.Add(ca);
             bd.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("No se aceptan valores vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }
Esempio n. 13
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (txtDireccion.Text != "" && txtNombre.Text != "" && txtTelefono.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             Proveedore pro = new Proveedore();
             pro.nombre_proveedor = txtNombre.Text;
             pro.telefono         = txtTelefono.Text;
             pro.direccion        = txtDireccion.Text;
             bd.Proveedores.Add(pro);
             bd.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("No se pueden guardar \n" +
                         "valores nulos");
     }
     limpiar();
     bloqueo();
     cargar();
 }
Esempio n. 14
0
 private void btnModificar_Click(object sender, EventArgs e)
 {
     if (txtNombre.Text != "")
     {
         using (VENTASEntities bd = new VENTASEntities())
         {
             Categoria ca  = new Categoria();
             string    id  = dgvCategorias.CurrentRow.Cells[0].Value.ToString();
             int       id2 = int.Parse(id);
             ca = bd.Categorias.Where(verificarId => verificarId.id_categoria == id2).First();
             ca.nombre_categoria = txtNombre.Text;
             bd.Entry(ca).State  = System.Data.Entity.EntityState.Modified;
             bd.SaveChanges();
         }
     }
     else
     {
         MessageBox.Show("No se aceptan valores vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }
Esempio n. 15
0
        private void btnFacturar_Click(object sender, EventArgs e)
        {
            using (VENTASEntities bd = new VENTASEntities())
            {
                Venta    tbV = new Venta();
                Empleado em  = new Empleado();
                Cliente  cli = new Cliente();

                if (txtNombreCliente.Text != "" && txtApellidoCliente.Text != "" && txtTelefono.Text != "" && txtDUI.Text != "" && txtDireccion.Text != "")

                {
                    if (cbFactura.Checked == true && cbTickect.Checked == false)
                    {
                        em = bd.Empleados.Where(idBuscar => idBuscar.nombre_empleado == lblNombreCajero.Text).First();
                        int idEmpleado = em.id_empleado;

                        string buscarCliente = txtDUI.Text;
                        cli = bd.Clientes.Where(idBuscar => idBuscar.dui == buscarCliente).First();


                        tbV.id_documento = 1;
                        tbV.id_cliente   = cli.id_cliente;
                        tbV.id_empleado  = idEmpleado;
                        tbV.total_venta  = Convert.ToDecimal(lblTotal.Text);
                        tbV.fecha        = Convert.ToDateTime(dtpFecha.Text);
                        bd.Ventas.Add(tbV);
                        bd.SaveChanges();
                    }
                    else if (cbTickect.Checked == true && cbFactura.Checked == false)
                    {
                        em = bd.Empleados.Where(idBuscar => idBuscar.nombre_empleado == lblNombreCajero.Text).First();
                        int idEmpleado = em.id_empleado;

                        tbV.id_documento = 2;
                        tbV.id_cliente   = 1;
                        tbV.id_empleado  = idEmpleado;
                        tbV.total_venta  = Convert.ToDecimal(lblTotal.Text);
                        tbV.fecha        = Convert.ToDateTime(dtpFecha.Text);
                        bd.Ventas.Add(tbV);
                        bd.SaveChanges();
                    }


                    Detalle_Venta dete = new Detalle_Venta();


                    for (int i = 0; i < dgvDetalleVenta.RowCount; i++)
                    {
                        string idProducto   = dgvDetalleVenta.Rows[i].Cells[0].Value.ToString();
                        int    idConvertido = Convert.ToInt32(idProducto);

                        string Cantidad           = dgvDetalleVenta.Rows[i].Cells[3].Value.ToString();
                        int    CantidadConvertido = Convert.ToInt32(Cantidad);

                        string  Total           = dgvDetalleVenta.Rows[i].Cells[4].Value.ToString();
                        decimal TotalConvertido = Convert.ToDecimal(Total);


                        dete.id_venta    = Convert.ToInt32(lblIdVenta.Text);
                        dete.id_producto = idConvertido;
                        dete.cantidad    = CantidadConvertido;
                        dete.precio      = TotalConvertido;
                        bd.Detalle_Venta.Add(dete);
                        bd.SaveChanges();
                    }

                    Producto pro = new Producto();

                    for (int i = 0; i < dgvDetalleVenta.RowCount; i++)
                    {
                        //OBTENIENDO DATOS

                        string idProducto   = dgvDetalleVenta.Rows[i].Cells[0].Value.ToString();
                        int    idConvertido = Convert.ToInt32(idProducto);

                        string Cantidad           = dgvDetalleVenta.Rows[i].Cells[3].Value.ToString();
                        int    CantidadConvertido = Convert.ToInt32(Cantidad);

                        pro = bd.Productos.Where(BuscarId => BuscarId.id_producto == idConvertido).First();
                        int existencias = Convert.ToInt32(pro.cantidad);

                        //ELIMINANDO EN INVENTARIO

                        int restar = existencias - CantidadConvertido;

                        pro.cantidad        = restar;
                        bd.Entry(pro).State = System.Data.Entity.EntityState.Modified;
                        bd.SaveChanges();
                    }

                    //IMPRIMIENDO FACTURA

                    pdImprimir = new PrintDocument();
                    PrinterSettings ps = new PrinterSettings();
                    pdImprimir.PrinterSettings = ps;
                    pdImprimir.PrintPage      += Imprimir;
                    pdImprimir.Print();



                    limpiarproducto();
                    LimpiarCliente();
                    dgvDetalleVenta.Rows.Clear();
                    RetornarId();
                    lblTotal.Text = "";
                    MessageBox.Show("Venta Guardada con exito");
                }
                else
                {
                    MessageBox.Show("No se han definido algunos valores");
                }
            }
        }
 private void btnModificar_Click(object sender, EventArgs e)
 {
     if (txtCantidad.Text != "" && txtNombre.Text != "" && txtCosto.Text != "" && txtVenta.Text != "")
     {
         if (cmbProveedor.Text == "" && cmbCategoria.Text != "")
         {
             using (VENTASEntities bd = new VENTASEntities())
             {
                 Producto pro = new Producto();
                 string   id  = dgvProductos.CurrentRow.Cells[0].Value.ToString();
                 int      id2 = int.Parse(id);
                 pro = bd.Productos.Where(verificarId => verificarId.id_producto == id2).First();
                 pro.id_categoria    = int.Parse(cmbCategoria.SelectedValue.ToString());
                 pro.nombre_producto = txtNombre.Text;
                 pro.cantidad        = int.Parse(txtCantidad.Text);
                 pro.costo           = decimal.Parse(txtCosto.Text);
                 pro.precio_venta    = decimal.Parse(txtVenta.Text);
                 bd.Entry(pro).State = System.Data.Entity.EntityState.Modified;
                 bd.SaveChanges();
                 listaProveedores();
             }
         }
         else if (cmbCategoria.Text == "" && cmbProveedor.Text != "")
         {
             using (VENTASEntities bd = new VENTASEntities())
             {
                 Producto pro = new Producto();
                 string   id  = dgvProductos.CurrentRow.Cells[0].Value.ToString();
                 int      id2 = int.Parse(id);
                 pro = bd.Productos.Where(verificarId => verificarId.id_producto == id2).First();
                 pro.id_proveedor    = int.Parse(cmbProveedor.SelectedValue.ToString());
                 pro.nombre_producto = txtNombre.Text;
                 pro.cantidad        = int.Parse(txtCantidad.Text);
                 pro.costo           = decimal.Parse(txtCosto.Text);
                 pro.precio_venta    = decimal.Parse(txtVenta.Text);
                 bd.Entry(pro).State = System.Data.Entity.EntityState.Modified;
                 bd.SaveChanges();
                 listaProveedores();
             }
         }
         else if (cmbCategoria.Text == "" && cmbProveedor.Text == "")
         {
             using (VENTASEntities bd = new VENTASEntities())
             {
                 Producto pro = new Producto();
                 string   id  = dgvProductos.CurrentRow.Cells[0].Value.ToString();
                 int      id2 = int.Parse(id);
                 pro = bd.Productos.Where(verificarId => verificarId.id_producto == id2).First();
                 pro.nombre_producto = txtNombre.Text;
                 pro.cantidad        = int.Parse(txtCantidad.Text);
                 pro.costo           = decimal.Parse(txtCosto.Text);
                 pro.precio_venta    = decimal.Parse(txtVenta.Text);
                 bd.Entry(pro).State = System.Data.Entity.EntityState.Modified;
                 bd.SaveChanges();
                 listaProveedores();
             }
         }
         else if (cmbCategoria.Text != "" && cmbProveedor.Text != "")
         {
             using (VENTASEntities bd = new VENTASEntities())
             {
                 Producto pro = new Producto();
                 string   id  = dgvProductos.CurrentRow.Cells[0].Value.ToString();
                 int      id2 = int.Parse(id);
                 pro = bd.Productos.Where(verificarId => verificarId.id_producto == id2).First();
                 pro.id_categoria    = int.Parse(cmbCategoria.SelectedValue.ToString());
                 pro.id_proveedor    = int.Parse(cmbProveedor.SelectedValue.ToString());
                 pro.nombre_producto = txtNombre.Text;
                 pro.cantidad        = int.Parse(txtCantidad.Text);
                 pro.costo           = decimal.Parse(txtCosto.Text);
                 pro.precio_venta    = decimal.Parse(txtVenta.Text);
                 bd.Entry(pro).State = System.Data.Entity.EntityState.Modified;
                 bd.SaveChanges();
                 listaProveedores();
             }
         }
     }
     else
     {
         MessageBox.Show("No se aceptan valores vacios");
     }
     limpiar();
     bloqueo();
     cargar();
 }