Esempio n. 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Afiliado afiliado = new Afiliado();

                afiliado.Nombre       = txtNombreAfiliado.Text;
                afiliado.Telefono     = txtTelefono.Text;
                afiliado.CodigoPostal = txtCodigoPostal.Text;
                afiliado.Ciudad       = txtCiudad.Text;
                afiliado.Calle        = txtCalle.Text;
                afiliado.Porsentaje   = txtPorsentaje.Text;
                afiliado.Activo       = ckbActivo.Checked;
                afiliado.NumeroOrden  = txtNumeroOrden.Text;
                afiliado.Correo       = txtCorreo.Text;



                db.Afiliados.Add(afiliado);
                db.SaveChanges();

                MessageBox.Show("Dato Insertado");
                dgvAfiliado.DataSource = db.Afiliados.ToList();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(txtCodigo.Text.Trim()))
                {
                    Productos productos = new Productos();

                    productos.CodigoId     = int.Parse(txtCodigo.Text);
                    productos.Nombre       = txtNombre.Text;
                    productos.Categoria    = txtCategoria.Text;
                    productos.Provedor     = txtProveedor.Text;
                    productos.PrecioCompra = double.Parse(txtPrecioCompra.Text);
                    productos.PrecioVenta  = double.Parse(txtPrecioVenta.Text);
                    productos.Cantidad     = double.Parse(txtCantidadInventario.Text);
                    var Codigo = CodigoBarras(int.Parse(txtCodigo.Text));
                    productos.Imagen = Codigo;

                    db.Productos.Add(productos);
                    db.SaveChanges();

                    dvgProductos.DataSource = db.Productos.ToList();
                }
            }
            catch (Exception)
            {
            }
        }
        public IHttpActionResult PutDepartment(int id, Department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != department.Id)
            {
                return(BadRequest());
            }

            db.Entry(department).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Servicios servicio = new Servicios();

                servicio.VisualizarServicio = txtVisualizarServicio.Text;
                servicio.NombreServicio     = txtNombreServicio.Text;
                servicio.Prefijo            = txtPrefijo.Text;
                servicio.Impuesto           = cmbImpuesto.SelectedIndex.ToString();
                servicio.Afiliado           = cmbAfiliado.SelectedIndex.ToString();
                servicio.Descuentos         = cmbDescuentos.SelectedIndex.ToString();
                servicio.Alerta             = ckbAlerta.Checked;
                servicio.Habilitar          = ckbHabilitar.Checked;
                servicio.Imagen             = txtRutaServicio.Text;



                db.Servicios.Add(servicio);
                db.SaveChanges();

                MessageBox.Show("Dato Insertado");
                dvgServicios.DataSource = db.Servicios.ToList();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Empleado empleado = new Empleado();

                empleado.Nombre     = txtNombre.Text;
                empleado.Apellidos  = txtApellidos.Text;
                empleado.Alias      = txtAlias.Text;
                empleado.Email      = txtEmal.Text;
                empleado.Activo     = ckbActivo.Checked;
                empleado.Usuario    = txtUsuario.Text;
                empleado.Clave      = txtClave.Text;
                empleado.SucursalId = cmbSucursal.SelectedValue.ToString();
                if (cmbRol.SelectedIndex == 0)
                {
                    empleado.Rol = "A";
                }
                if (cmbRol.SelectedIndex == 1)
                {
                    empleado.Rol = "C";
                }
                if (cmbRol.SelectedIndex == 2)
                {
                    empleado.Rol = "E";
                }
                empleado.RecibirInforme    = ckbRecibeinfo.Checked;
                empleado.ResivirNotifica   = ckbrecibeNotifi.Checked;
                empleado.EditPagina        = ckbEditPagina.Checked;
                empleado.EditSegundaPagina = ckbEditSegunda.Checked;
                empleado.ApcederTarjeta    = ckbapcedeTarjeta.Checked;
                empleado.AbrirCajon        = ckbAbrirCajon.Checked;
                empleado.EditCreditoClinte = ckbEditCredito.Checked;
                empleado.EditPuntosClinte  = ckbEditPuntos.Checked;
                empleado.desdelunes        = TimeSpan.Parse(duddesdelunes.Value.ToString("HH:mm"));
                empleado.desdemartes       = TimeSpan.Parse(duddesdemartes.Value.ToString("HH:mm"));
                empleado.desdemiercoles    = TimeSpan.Parse(duddesdemiercoles.Value.ToString("HH:mm"));
                empleado.desdejueves       = TimeSpan.Parse(duddesdejueves.Value.ToString("HH:mm"));
                empleado.desdesabado       = TimeSpan.Parse(duddesdeviernes.Value.ToString("HH:mm"));
                empleado.desdeviernes      = TimeSpan.Parse(duddesdesabado.Value.ToString("HH:mm"));
                empleado.desdedomingo      = TimeSpan.Parse(duddesdedomingo.Value.ToString("HH:mm"));
                empleado.hastalunes        = TimeSpan.Parse(dudhastalunes.Value.ToString("HH:mm"));
                empleado.hastamartes       = TimeSpan.Parse(dudhastamartes.Value.ToString("HH:mm"));
                empleado.hastamiercoles    = TimeSpan.Parse(dudhastamiercoles.Value.ToString("HH:mm"));
                empleado.hastajueves       = TimeSpan.Parse(dudhastajueves.Value.ToString("HH:mm"));
                empleado.hastasabado       = TimeSpan.Parse(dudhastaviernes.Value.ToString("HH:mm"));
                empleado.hastaviernes      = TimeSpan.Parse(dudhastasabado.Value.ToString("HH:mm"));
                empleado.hastadomingo      = TimeSpan.Parse(dudhastadomingo.Value.ToString("HH:mm"));


                db.Empleados.Add(empleado);
                db.SaveChanges();

                MessageBox.Show("Empleado Guardado");
            }
            catch (Exception)
            {
            }
        }
Esempio n. 6
0
        async void  ClickCambiarEstado(object sender, EventArgs e)
        {
            try
            {
                frmPin pin = new frmPin();
                this.Opacity = 0.80;
                pin.ShowDialog();
                this.Close();
                this.Opacity = 1;


                if (Program.Pin != null)
                {
                    var Mensaje = MessageBox.Show("Esta Seguro desea Completar Orden", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (Mensaje == DialogResult.Yes)
                    {
                        Button btn = sender as Button;
                        var    id  = int.Parse(btn.Text);

                        var Orden = db.Ordenes.Find(id);

                        Orden.Prendas.SelectMany(m => m.DetalleTareas).ToList().ForEach(w => { w.Estado = true; w.EmpleadoActualizo = Program.Pin; });
                        foreach (var item in listaTareas)
                        {
                            item.btnEstado.BackColor = Color.OliveDrab;
                        }
                        Orden.EstadoId          = 1;
                        Orden.EmpleadoActualizo = Program.Pin;
                        Orden.EmpleadoCompleto  = Program.Pin;
                        db.SaveChanges();
                        var ordenView = listaOrdenes.Where(w => w.OrdenId == Orden.OrdenId).FirstOrDefault();
                        ordenView.btnEstado.BackColor = Color.OliveDrab;
                        var TempleisEmpresa = db.ConfiguracionEnvios.ToList();
                        var Detalle         = db.Templeis.FirstOrDefault().TempleiSMS;
                        Detalle = Detalle.Replace("{FirstName}", Orden.Cliente.Nombre + "%0A")
                                  .Replace("{OrderId(s)}", Orden.OrdenId.ToString() + "%0A")
                                  .Replace("{BusinessName}", TempleisEmpresa.FirstOrDefault().NombreEmpresa);
                        System.Diagnostics.Process.Start("https://web.whatsapp.com/send?phone=506" + Orden.Cliente.TelefonoPrincipal + "&text=" + Detalle);
                        var Email  = db.Templeis.FirstOrDefault().TempleiEmail;
                        var Subjet = "Su Orden Esta Lista Para Ser Retirada";
                        Email = Email.Replace("{ClientName}", Orden.Cliente.Nombre)
                                .Replace("{OrderId(s)}", Orden.OrdenId.ToString())
                                .Replace("{BusinessName}", TempleisEmpresa.FirstOrDefault().NombreEmpresa)
                                .Replace("{AddressLine1}", TempleisEmpresa.FirstOrDefault().DirrecionLinea1)
                                .Replace("{AddressLine2}", TempleisEmpresa.FirstOrDefault().DirrecionLinea2)
                                .Replace("P: {BusinessPhone}", TempleisEmpresa.FirstOrDefault().Telefono)
                                .Replace("W: {BusinessWebsite}", TempleisEmpresa.FirstOrDefault().PaginaWeb)
                                .Replace("E: {BusinessEmail}", TempleisEmpresa.FirstOrDefault().CorreoEmpresa);
                        await EnvioCorreos.SendMail(Orden.Cliente.Email, Subjet, Email);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Prenda prenda = new Prenda();

                prenda.Imagen       = txtRuta.Text;
                prenda.TipoRopa     = txtTipoRopa.Text;
                prenda.NumeroPrenda = txtNumeroPrenda.Text;
                prenda.piezas       = txtPiezas.Text;



                db.Prendas.Add(prenda);
                db.SaveChanges();

                MessageBox.Show("Dato Insertado");
                dvgRopa.DataSource = db.Prendas.Select(x => new { x.PrendaId, x.TipoRopa, x.piezas, x.NumeroPrenda }).ToList();

                dvgRopa.ClearSelection();
                dvgRopa.Rows[dvgRopa.Rows.Count - 1].Selected = true;
                var prendaid = int.Parse(dvgRopa.SelectedRows[0].Cells[0].Value.ToString());
                dgvTarea.DataSource = db.Tareas.Where(x => x.PrendaId == prendaid).ToList();
            }
            catch (Exception)
            {
            }
        }
        public ActionResult Create(Country country)
        {
            if (ModelState.IsValid)
            {
                db.Countries.Add(country);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(country));
        }
Esempio n. 9
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            Sucursal sucursal = new Sucursal();

            sucursal.Nombre = txtNombre.Text;
            sucursal.Activa = ckbActivo.Checked;

            db.Sucursales.Add(sucursal);
            db.SaveChanges();

            listSucursales.DataSource = db.Sucursales.ToList();
        }
        public ActionResult Create(Athlete athlete)
        {
            if (ModelState.IsValid)
            {
                db.Athletes.Add(athlete);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdCountry = new SelectList(db.Countries, "IdCountry", "Name", athlete.IdCountry);
            return(View(athlete));
        }
Esempio n. 11
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            Pagos pago = db.Pagos.Find(int.Parse(txtIdOrden.Text));

            pago.Monto           = double.Parse(txtMonto.Text);
            pago.MedioPagoId     = int.Parse(cmbMedioPago.SelectedValue.ToString());
            pago.EmpleadoRealizo = CmbEmpleado.SelectedValue.ToString();
            db.Entry(pago).State = EntityState.Modified;
            db.SaveChanges();

            MessageBox.Show("Pago Actualizado");

            listPagos.DataSource = db.Pagos.Where(q => q.Fecha == DateTime.Today).Select(q => new { q.PagoId, q.Fecha, q.Monto, q.MediosPago.FormaPago, q.EmpleadoRealizo }).ToList();
        }
Esempio n. 12
0
        private void btnAgregarPago_Click(object sender, EventArgs e)
        {
            try
            {
                frmPin pin = new frmPin();
                this.Opacity = 0.80;
                pin.ShowDialog();
                this.Opacity = 1;
                var query = db.Pagos.Where(q => q.OrdenId == OrdenId).ToList();
                if (query.Count > 0)
                {
                    var   idPAgo      = query.FirstOrDefault().PagoId;
                    Pagos pagos       = db.Pagos.Find(idPAgo);
                    var   MontoActual = query.Last().Monto;

                    pagos.MedioPagoId = int.Parse(cbPagos.SelectedValue.ToString());
                    pagos.OrdenId     = OrdenId;
                    if (!string.IsNullOrEmpty(txtMonto.Text))
                    {
                        pagos.Monto = MontoActual - double.Parse(txtMonto.Text);
                    }
                    else
                    {
                        pagos.Monto = MontoActual - double.Parse("0");
                    }

                    db.Entry(pagos).State = EntityState.Modified;
                    db.SaveChanges();
                }
                Pagos pago = new Pagos();
                pago.Fecha           = DateTime.Today;
                pago.EmpleadoRealizo = Program.Pin;
                pago.Monto           = double.Parse(txtMonto.Text);

                pago.MedioPagoId = int.Parse(cbPagos.SelectedValue.ToString());
                pago.OrdenId     = OrdenId;
                db.Pagos.Add(pago);
                db.SaveChanges();

                Ordenes orden = db.Ordenes.Find(OrdenId);
                orden.CantidadPagada   = double.Parse(txtMonto.Text);
                orden.CantidadRestante = orden.CantidadRestante - double.Parse(txtMonto.Text);
                db.Entry(orden).State  = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 13
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            ConfiguracionEnvioCorreos configuracion = db.ConfiguracionEnvios.Find(1);

            configuracion.NombreEmpresa         = txtNombre.Text;
            configuracion.Emcabezado            = txtEncabezado.Text;
            configuracion.Dirrecion             = txtDirecionRecibo.Text;
            configuracion.Horario               = txtHorario.Text;
            configuracion.PiePagina             = txtPiePagina.Text;
            configuracion.DirrecionLinea1       = txtDirecionLinea1.Text;
            configuracion.DirrecionLinea2       = txtDirecionLinea2.Text;
            configuracion.Telefono              = txtTelefono.Text;
            configuracion.PaginaWeb             = txtSitioWeb.Text;
            configuracion.NumeroEmpresa         = txtNumeroEmpresa.Text;
            configuracion.MontoInicialCaja      = double.Parse(txtMontoCaja.Text);
            configuracion.CantidadDineroPorHora = double.Parse(txtMontoOrdenes.Text);
            configuracion.STPMinutos            = txtSTP.Text;
            configuracion.CorreoEmpresa         = txtCorreo.Text;
            configuracion.SMSEmpresa            = txtSMS.Text;
            configuracion.ActivoCorreo          = ckbCorreo.Checked;
            configuracion.ActivoSMS             = ckbSMS.Checked;


            db.Entry(configuracion).State = EntityState.Modified;
            db.SaveChanges();

            MessageBox.Show("Dato Actualizado");
        }
        private void btnActualizarCliente_Click(object sender, EventArgs e)
        {
            this.Opacity = 0.99;
            this.Close();
            Program.abrirform = 3;

            frmPin frmPin = new frmPin();

            frmPin.ShowDialog();
            Cliente cliente = db.Clientes.Find(ClienteId);


            cliente.Nombre            = txtNombre.Text;
            cliente.Email             = txtEmail.Text;
            cliente.Calle             = txtCalle.Text;
            cliente.Ciudad            = txtCiudad.Text;
            cliente.TelefonoPrincipal = txtTelefonoPrincipal.Text;
            cliente.TelefonoDos       = txtTelefono2.Text;
            cliente.Telefonotres      = txtTelefono3.Text;

            cliente.Codigopostal      = txtCodigoPostal.Text;
            cliente.FechaModificacion = DateTime.Now.ToString("dd/MM/yyyy") + " " + DateTime.Now.ToString("HH:mm:ss");
            cliente.Empleadoactualiza = Program.Pin;



            db.Entry(cliente).State = EntityState.Modified;
            db.SaveChanges();
            frmPrincipal frm = new frmPrincipal();

            frm.Opacity = 1;
            frm.Show();
        }
Esempio n. 15
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                MediosPago mediopago = new MediosPago();

                mediopago.FormaPago       = txtFormaPago.Text;
                mediopago.CodigosCuentas  = txtCodigoCuentas.Text;
                mediopago.VisualizarOrden = txtVirualisarOrden.Text;
                mediopago.TipoMedio       = cmbMedioPago.SelectedItem.ToString();
                mediopago.AbrirCajon      = ckbAbrirCAjon.Checked;
                mediopago.IncluirTotal    = ckbIncluirtotal.Checked;



                db.MediosPago.Add(mediopago);
                db.SaveChanges();

                MessageBox.Show("Dato Insertado");
                dvgMediosPago.DataSource = db.MediosPago.ToList();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 16
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Templeis templeis = db.Templeis.Find(1);

                templeis.TempleiSMS                 = txtPlantillaSMS.Text;
                templeis.TempleiEmail               = txtPlantillaCorreo.Text;
                templeis.DirrecTempleiFactura       = txtPlantillaFactura.Text;
                templeis.DirrecTempleiVenta         = txtPlantillaVenta.Text;
                templeis.DirrecTempleiFacturaMaciva = txtPlantillaCorreoMacivo.Text;
                templeis.SubTempleiFactura          = txtSubFActura.Text;
                templeis.SubTempleiVenta            = txtSubCorreo.Text;
                templeis.SubTempleiFacturaMaciva    = txtSubMaciva.Text;


                db.Entry(templeis).State = EntityState.Modified;
                db.SaveChanges();

                MessageBox.Show("Dato Actualizado");
            }
            catch (Exception)
            {
            }
        }
Esempio n. 17
0
        void SumatoriaPrecios()
        {
            try
            {
                using (var db = new DataContextLocal())
                {
                    var Detalle = db.DetalleVentas.Where(q => q.VentaId == ventaId).ToList();

                    txtpangandoahora.Text = Detalle.Sum(q => q.Subtotal).ToString();
                    lblTotal.Text         = Detalle.Sum(q => q.Subtotal).ToString();
                    var Venta = db.Ventas.Find(ventaId);
                    Venta.TotalOrden      = double.Parse(txtpangandoahora.Text);
                    db.Entry(Venta).State = EntityState.Modified;
                    db.SaveChanges();
                    var Subtotal    = 0.0;
                    var Descuento   = 0.0;
                    var ultimatarea = listaProductos.Last();
                    foreach (var item in Detalle)
                    {
                        var Cantidad = item.Cantidad;
                        var Precio   = item.Precio;
                        Subtotal              += (Cantidad * Precio);
                        Descuento             += ((Cantidad * Precio) * item.Descuento / 100);
                        lblSubTotalabajo.Text  = Subtotal.ToString();
                        lblDescuentoAbajo.Text = Descuento.ToString();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 18
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            Ofertas oferta = new Ofertas();

            oferta.NumeroOferta        = txtNumeroOferta.Text;
            oferta.Descripcion         = txtDescripcion.Text;
            oferta.DescuentoPorsentaje = int.Parse(txtDescuento.Text);
            oferta.ImporteDescuento    = txtImporte.Text;
            oferta.Habilitar           = ckbHabilitar.Checked;


            db.Ofertas.Add(oferta);
            db.SaveChanges();

            MessageBox.Show("Oferta Guardada");
            dvgOfertas.DataSource = db.Ofertas.ToList();
        }
Esempio n. 19
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            Cliente cliente = new Cliente();



            db.Clientes.Add(cliente);
            db.SaveChanges();

            MessageBox.Show("Dato Insertado");
        }
Esempio n. 20
0
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            try
            {
                using (var db = new DataContextLocal())
                {
                    var Mensaje = MessageBox.Show("Esta Seguro desea Salir Y Borrar Esa Venta Del Sistema", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (Mensaje == DialogResult.Yes)
                    {
                        var detalle = db.DetalleVentas.Where(q => q.VentaId == ventaId).ToList();
                        if (detalle.Count > 0)

                        {
                            foreach (var item in detalle)
                            {
                                db.DetalleVentas.Remove(item);
                                db.SaveChanges();
                            }
                        }



                        Ventas venta = db.Ventas.Find(ventaId);
                        db.Ventas.Remove(venta);
                        db.SaveChanges();



                        this.Close();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                ImpresionesAutomaticas impresiones = new ImpresionesAutomaticas();

                impresiones.NumeroImprecion = txtNumeroImpresion.Text;
                if (rbPlantillaCliente.Checked == true)
                {
                    impresiones.TipoImpresion = rbPlantillaCliente.Text;
                }
                if (rbPlantillaPersonalizada.Checked == true)
                {
                    impresiones.TipoImpresion = rbPlantillaPersonalizada.Text;
                }
                if (rbVenta.Checked == true)
                {
                    impresiones.TipoImpresion = rbVenta.Text;
                }

                if (rbPlantillaTienda.Checked == true)
                {
                    impresiones.TipoImpresion = rbPlantillaTienda.Text;
                }
                if (rbOrden.Checked == true)
                {
                    impresiones.TipoImpresion = rbOrden.Text;
                }


                impresiones.Precio       = ckbPrecio.Checked;
                impresiones.CodigoBarras = ckbCodigoBarras.Checked;
                impresiones.Servicio     = cmbServicios.SelectedIndex.ToString();



                db.impresiones.Add(impresiones);
                db.SaveChanges();

                MessageBox.Show("Dato Insertado");
                dvgImpresiones.DataSource = db.impresiones.ToList();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 22
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            OpcionesOrdenes opcionesOrdenes = new OpcionesOrdenes();

            opcionesOrdenes.NombreOpcion = txtNombreOpcion.Text;
            opcionesOrdenes.NumeroOpcion = txtNumeroOpcion.Text;
            opcionesOrdenes.TipoOpcion   = cmbTipoOpcion.SelectedIndex.ToString();
            opcionesOrdenes.Precio       = txtPrecio.Text;



            db.opcionesOrdenes.Add(opcionesOrdenes);
            db.SaveChanges();

            MessageBox.Show("Dato Insertado");
            dgvOpcionesOrdenes.DataSource = db.opcionesOrdenes.ToList();
        }
Esempio n. 23
0
        private static int CreateStatusMatchByName(string statusMatchName, DataContextLocal dbLocal)
        {
            try
            {
                var statusMacth = new StatusMatch
                {
                    Name = statusMatchName,
                };

                dbLocal.Entry(statusMatchName);
                dbLocal.SaveChanges();

                return(statusMacth.StatusMatchId);
            }
            catch (Exception)
            {
                return(-1);
            }
        }
Esempio n. 24
0
        public static void Add(int id, string nombre, bool activa)
        {
            try
            {
                using (DataContextLocal db = new DataContextLocal())
                {
                    var horario = new HorarioRubro
                    {
                        HorarioRubroId = id,
                        Nombre         = nombre,
                        Activo         = activa,
                    };

                    db.HorarioRubros.Add(horario);
                    db.SaveChanges();
                }
            }
            catch
            {
            }
        }
Esempio n. 25
0
        public static void Add(int id, string nombre, bool activa)
        {
            try
            {
                using (DataContextLocal db = new DataContextLocal())
                {
                    var tipo = new TipoPago
                    {
                        TipoPagoId = id,
                        Nombre     = nombre,
                        Activo     = activa,
                    };

                    db.TipoPagos.Add(tipo);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 26
0
        public static void Add(int estadoCivilId, string nombre, bool activa)
        {
            try
            {
                using (DataContextLocal db = new DataContextLocal())
                {
                    var estadoCivil = new EstadoCivil
                    {
                        EstadoCivilId = estadoCivilId,
                        Nombre        = nombre,
                        Activa        = activa,
                    };

                    db.EstadosCiviles.Add(estadoCivil);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 27
0
        public static void Add(int id, string nombre, bool activa)
        {
            try
            {
                using (DataContextLocal db = new DataContextLocal())
                {
                    var item = new EstadoMarca
                    {
                        EstadoMarcaId = id,
                        Nombre        = nombre,
                        Activa        = activa,
                    };

                    db.EstadoMarcas.Add(item);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 28
0
        public static void Add(int id, string nombre, Color color)
        {
            try
            {
                using (DataContextLocal db = new DataContextLocal())
                {
                    var estado = new Estados
                    {
                        EstadoId = id,
                        Nombre   = nombre,
                        Color    = color,
                    };

                    db.Estados.Add(estado);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 29
0
        void GuardarCambiosProductos()
        {
            try
            {
                using (var db = new DataContextLocal())
                {
                    var ultimatarea = listaProductos.Last();



                    var consulta  = db.DetalleVentas.Where(q => q.VentaId == ventaId).ToList();
                    var IdDetalle = consulta.LastOrDefault().DetalleVentasId;

                    var CantidadArticulos = int.Parse(ultimatarea.txtPrecio.Text);

                    DetalleVentas detalle = db.DetalleVentas.Find(IdDetalle);

                    detalle.Cantidad  = CantidadArticulos;
                    detalle.Subtotal  = double.Parse(ultimatarea.lblSubTotal.Text);
                    detalle.Descuento = Descuento;

                    try
                    {
                        db.Entry(detalle).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                    }


                    SumatoriaPrecios();
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 30
0
        private async void button1_Click(object sender, EventArgs e)
        {
            lblMensaje.Text      = "Procesando...";
            lblMensaje.ForeColor = System.Drawing.Color.Gray;

            OpenFileDialog openFileDialog1 = new OpenFileDialog();


            openFileDialog1.Title = "Buscar Importar";

            openFileDialog1.CheckFileExists = true;

            openFileDialog1.CheckPathExists = true;



            openFileDialog1.DefaultExt = ".xlsx";

            openFileDialog1.Filter = "Text files (*.xlsx)|*.xls|All files (*.*)|*.*";

            openFileDialog1.FilterIndex = 2;

            openFileDialog1.RestoreDirectory = true;



            openFileDialog1.ReadOnlyChecked = true;

            openFileDialog1.ShowReadOnly = true;



            if (openFileDialog1.ShowDialog() == DialogResult.OK)

            {
                textBox1.Text = openFileDialog1.FileName;
            }
            if (openFileDialog1.FileName.EndsWith("xls") || openFileDialog1.FileName.EndsWith("xlsx"))
            {
                //readv data file
                Microsoft.Office.Interop.Excel.Application application = new Microsoft.Office.Interop.Excel.Application();
                Microsoft.Office.Interop.Excel.Workbook    workbook    = application.Workbooks.Open(textBox1.Text);
                Microsoft.Office.Interop.Excel.Worksheet   worksheet   = workbook.ActiveSheet;
                Microsoft.Office.Interop.Excel.Range       range       = worksheet.UsedRange;
                var fila = 0;
                try
                {
                    Marca marca = new Marca();
                    MarcaViewModelImport viewImport = new MarcaViewModelImport();

                    for (int row = 2; row <= range.Rows.Count; row++)
                    {
                        fila             = row;
                        lblContador.Text = "(" + (row - 1).ToString() + "/" + (range.Rows.Count - 1).ToString() + ")";

                        var ubicacionId = FindUbicacionId(((Microsoft.Office.Interop.Excel.Range)range.Cells[row, 1]).Text);

                        var personaId = FindPersonaId(((Microsoft.Office.Interop.Excel.Range)range.Cells[row, 2]).Text, ubicacionId);

                        if (personaId > 0)
                        {
                            marca.UbicacionId      = ubicacionId;
                            marca.PersonaId        = personaId;
                            viewImport.Fecha       = ((Microsoft.Office.Interop.Excel.Range)range.Cells[row, 3]).Text;
                            viewImport.HoraEntrada = ((Microsoft.Office.Interop.Excel.Range)range.Cells[row, 4]).Text;
                            viewImport.HoraSalida  = ((Microsoft.Office.Interop.Excel.Range)range.Cells[row, 5]).Text;
                            viewImport.HoraOT      = ((Microsoft.Office.Interop.Excel.Range)range.Cells[row, 6]).Text;

                            var persona = await db.Personas.FindAsync(marca.PersonaId);

                            marca = ToMarca(marca, viewImport);

                            //Ponemos estado normal en caso de que las horas sean las mismas
                            if (marca.HorasTrabajadas.Hours == persona.Puesto.Horas)
                            {
                                marca.EstadoMarcaId = 1;
                            }

                            db.Marcas.Add(marca);
                            db.SaveChanges();

                            if (marca.HorasTrabajadas.Hours != persona.Puesto.Horas)
                            {
                                var justificacion = new Justificacion
                                {
                                    FechaCreacion = DateTime.Now,
                                    SubordinadoId = personaId,
                                    SupervisorId  = persona.SupervisorId,
                                };
                                db.Justificaciones.Add(justificacion);
                                await db.SaveChangesAsync();

                                var notificacion = new NotificacionPersona
                                {
                                    Activo    = true,
                                    Fecha     = DateTime.Now,
                                    Nota      = "Solicitud de Justificación " + persona.NombreCompleto,
                                    Titulo    = "Justificación",
                                    PersonaId = persona.SupervisorId.Value,
                                };

                                db.NotificacionPersonas.Add(notificacion);
                                await db.SaveChangesAsync();
                            }
                        }
                    }

                    range     = null;
                    worksheet = null;
                    workbook.Close(false, Type.Missing, Type.Missing);

                    application.Quit();

                    KillExcel(application);

                    System.Runtime.InteropServices.Marshal.ReleaseComObject(application);
                    workbook    = null;
                    application = null;

                    lblMensaje.Text      = "Finalizado correctamente...";
                    lblMensaje.ForeColor = System.Drawing.Color.Green;
                }
                catch (Exception ex)
                {
                    lblMensaje.Text = "Error por favor revise el archivo - Fila (" + fila + ")";
                    if (ex.InnerException != null)
                    {
                        lblMensaje.Text      = (Char)13 + ex.InnerException.Message.ToString();
                        lblMensaje.ForeColor = System.Drawing.Color.Red;
                    }
                    else if (ex.Message != null)
                    {
                        lblMensaje.Text      = (Char)13 + ex.Message.ToString();
                        lblMensaje.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            else
            {
                lblMensaje.Text      = "El archivo no es correcto...";
                lblMensaje.ForeColor = System.Drawing.Color.Red;
            }
        }