Beispiel #1
0
        public void EstadoVencido(string folio)
        {
            Boleta bol = _entidades.Boletas.Single(b => b.Folio == folio);

            bol.EstadoBoleta = "Vencido";
            _entidades.SubmitChanges();
        }
 public int AgregarGrupo(FinancieraGrupo grupo)
 {
     if (grupo.Nombre == string.Empty)
     {
         throw new ValidationException("Indique el nombre del Grupo");
     }
     _entidades.FinancieraGrupos.InsertOnSubmit(grupo);
     _entidades.SubmitChanges();
     return(grupo.Clave);
 }
Beispiel #3
0
 public int AgregarCompra(Compra compra)
 {
     if (compra.TotalCompra == 0)
     {
         throw new ValidationException("El Monto de compra no puede ser cero");
     }
     _entidades.Compras.InsertOnSubmit(compra);
     _entidades.SubmitChanges();
     return(compra.CveCompra);
 }
Beispiel #4
0
 public int AgregarTransaccion(Transaccione item)
 {
     if (item.TipoTransaccion == "Retiro")
     {
         string per = _entidad.Usuarios.Single(u => u.CveUsuario == item.CveUsuario).Permisos;
         if (per == "Usuario")
         {
             throw new ValidationException("No tiene permisos para realizar Retiros");
         }
         if (ClsVerificarCaja.SaldoEnCaja() < item.Cantidad)
         {
             throw new ValidationException("No Puede retirar mas de lo disponible en caja");
         }
     }
     if (item.Cantidad == 0)
     {
         throw new ValidationException("La cantidad no puede ser cero");
     }
     if (item.TipoTransaccion == string.Empty)
     {
         throw new ValidationException("Indique el tipo de transacción");
     }
     if (item.Concepto == string.Empty)
     {
         throw new ValidationException("Indique el concepto de la transacción");
     }
     _entidad.Transacciones.InsertOnSubmit(item);
     _entidad.SubmitChanges();
     return(item.Clave);
 }
        public void ActualizarGrupo(FinancieraGrupo nuevo, FinancieraGrupo original)
        {
            EmpeñosDC entidades = new EmpeñosDC(new clsConeccionDB().StringConn());

            entidades.FinancieraGrupos.Attach(nuevo, original);
            entidades.SubmitChanges();
        }
        private void botonDeleteSelected_Click(object sender, EventArgs e)
        {
            foreach (DataRow t in from DataRow t in _dtArticulos.Rows where (bool)t["S"] select t)
            {
                if (t[8].ToString() == "Disponible")
                {
                    var bolven = (_mapeoVentas.Articulos.Where(
                                      bol => bol.Clave == Convert.ToInt32(t[1].ToString()))).Single();
                    bolven.Estado = "Baja";
                }

                if (t[8].ToString() == "Apartado")
                {
                    Articulo art =
                        _mapeoVentas.Articulos.Single(
                            a => a.Clave == Convert.ToInt32(t[1]));
                    if (art != null)
                    {
                        art.Estado = "Baja";
                    }
                    var venta = (_mapeoVentas.DetalleVentas.Where(
                                     vta => vta.CveArticulo == Convert.ToInt32(t[1]))
                                 .Select(vta => vta.Venta)).Single();
                    venta.Estado = "Moroso";
                }
                _mapeoVentas.SubmitChanges();
            }
            LlenargridArticulos();
        }
Beispiel #7
0
 public void Guardar()
 {
     try
     {
         if (!ClsVerificarCaja.CajaEstado())
         {
             MessageBox.Show("La Caja del Dia de hoy ya se ha cerrado\n SISTEMA BLOQUEADO", "Caja Cerrada", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Application.Exit();
         }
         if ((int)txtCveAbono.EditValue == 0)
         {
             PagosVenta abono = new PagosVenta
             {
                 CveVenta   = Convert.ToInt32(txtCveVenta.EditValue),
                 Abono      = Convert.ToDecimal(txtAbono.EditValue),
                 Saldo      = Convert.ToDecimal(Convert.ToDecimal(txtSaldo.EditValue) - Convert.ToDecimal(txtAbono.EditValue)),
                 FechaPago  = dtpFechaAbono.DateTime.Date,
                 Estado     = true,
                 CveUsuario = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IDUsuarioApp")),
             };
             txtCveAbono.EditValue = new LogicaAbonosVentas().AgregarAbono(abono);
             Venta venta = _entidades.Ventas.Single(v => v.Clave == Convert.ToInt32(txtCveVenta.EditValue));
             if (abono.Saldo == 0)
             {
                 foreach (DetalleVenta detVta in venta.DetalleVentas)
                 {
                     Articulo art = detVta.Articulo;
                     art.Estado = "Vendido";
                 }
                 venta.Estado = "Pagado";
             }
             _entidades.SubmitChanges();
             ImprimirTicketsAbono();
             new ManejadorControles().DesectivarTextBox(gpoContenedor, false);
             var pagos = from p in _entidades.PagosVentas
                         where p.Estado && p.CveVenta == venta.Clave
                         select
                         new
             {
                 p.Clave,
                 p.Abono,
                 p.FechaPago,
                 Registró = p.Usuario.Nombre
             };
             gridAbonos.DataSource = pagos;
         }
         else if ((int)txtCveAbono.EditValue > 0)
         {
             ImprimirTicketsAbono();
         }
     }
     catch (ValidationException vex)
     {
         XtraMessageBox.Show(vex.Message, "Validación de Datos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message, "Error al Guardar", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public int InsertarVenta(Venta venta)
 {
     if (venta.Cliente == string.Empty)
     {
         throw new ValidationException("Indique el Nombre del cliente");
     }
     if (venta.TotalVenta == 0)
     {
         throw new ValidationException("Indique los Articulos a Vender");
     }
     if (venta.TipoVenta == "Apartado" && venta.Enganche == 0)
     {
         throw new ValidationException("Indique cuando es el enganche de la venta");
     }
     _entidades.Ventas.InsertOnSubmit(venta);
     _entidades.SubmitChanges();
     return(venta.Clave);
 }
Beispiel #9
0
        public int AgregarRegistro(Usuario item)
        {
            if (item.Nombre == string.Empty)
            {
                throw new ValidationException("El nombre no debe de estar vacio");
            }
            if (item.Usuario1.Length < 3)
            {
                throw new ValidationException("Nombre de Usuario muy corto");
            }
            if (item.Contrasenia.Length < 6)
            {
                throw new ValidationException("la contraseña deberia ser igual o mayor a 5 caracteres");
            }

            _entidades.Usuarios.InsertOnSubmit(item);
            _entidades.SubmitChanges();
            return(item.CveUsuario);
        }
 public int AgregarCredito(FinancieraCredito credito)
 {
     if (credito.CveGrupo == 0)
     {
         throw new ValidationException("Elija el Grupo para poder otorgar un credito");
     }
     _entidades.FinancieraCreditos.InsertOnSubmit(credito);
     _entidades.SubmitChanges();
     return(credito.Clave);
 }
Beispiel #11
0
 public int AgregarCliente(Cliente cli)
 {
     if (cli.Nombre == string.Empty)
     {
         throw new ValidationException("Indique el nombre del Cliente");
     }
     if (cli.Direccion == string.Empty)
     {
         throw new ValidationException("Indique la direccion Cliente");
     }
     if (cli.Poblacion == string.Empty)
     {
         throw new ValidationException("Indique el poblado del Cliente");
     }
     if (cli.Telefono == string.Empty && cli.Celular == string.Empty)
     {
         throw new ValidationException("Indique un numero de Telefono o Celular");
     }
     mapeoFinanciamiento.Clientes.InsertOnSubmit(cli);
     mapeoFinanciamiento.SubmitChanges();
     return(cli.CveCliente);
 }
Beispiel #12
0
 public int InsertarArticulo(Articulo art)
 {
     if (art.Descripcion == string.Empty)
     {
         throw new ValidationException("Indique la descripción del artículo");
     }
     if (art.Peso == 0)
     {
         throw new ValidationException("Indique el peso del artículo");
     }
     if (art.Precio == 0)
     {
         throw new ValidationException("Indique el Precio del Articulo");
     }
     if (art.PrecioCredito == 0)
     {
         throw new ValidationException("Indique el Precio Apartado");
     }
     _entidades.Articulos.InsertOnSubmit(art);
     _entidades.SubmitChanges();
     return(art.Clave);
 }
 private void GuardarReferencias(int cveprestamos)
 {
     for (int i = 0; i < _dtReferencias.Rows.Count; i++)
     {
         DetalleReferenciasPrestamo dtRef = new DetalleReferenciasPrestamo
         {
             CvePrestamo   = cveprestamos,
             CveReferencia = (int)_dtReferencias.Rows[i][0],
         };
         _entidades.DetalleReferenciasPrestamos.InsertOnSubmit(dtRef);
     }
     _entidades.SubmitChanges();
 }
Beispiel #14
0
 public int AgregarPrestamo(Prestamo pres)
 {
     if (pres.Tipo == string.Empty)
     {
         throw new ValidationException("Indique el tipo de Financiamiento");
     }
     if (pres.Cantidad <= 0)
     {
         throw new ValidationException("Indique el monto a Financiar");
     }
     _mapeoFinanciamiento.Prestamos.InsertOnSubmit(pres);
     _mapeoFinanciamiento.SubmitChanges();
     return(pres.Clave);
 }
Beispiel #15
0
 private void GuardarDetalle()
 {
     foreach (Prenda p in from DataRow prenda in _dtprenda.Rows
              select new Prenda
     {
         Descripcion = prenda[0].ToString(),
         Peso = Convert.ToDecimal(prenda[1]),
         Tipo = prenda[2].ToString(),
         Avaluo = Convert.ToDecimal(prenda[3]),
         Estado = "Empeño"
     })
     {
         _entidades.Prendas.InsertOnSubmit(p);
         _entidades.SubmitChanges();
         DetallesBoleta db = new DetallesBoleta
         {
             Folio     = txtFolioBoleta.Text,
             CvePrenda = p.Clave,
         };
         _entidades.DetallesBoletas.InsertOnSubmit(db);
         _entidades.SubmitChanges();
     }
 }
 public int AgregarPagoInteres(PagosIntere intere)
 {
     if (intere.FolioBoleta == string.Empty)
     {
         throw new ValidationException("Selecione la boleta a Abonar");
     }
     if (intere.Interes == 0)
     {
         throw new ValidationException("El Monto a pagar no puede ser cero");
     }
     _entidades.PagosInteres.InsertOnSubmit(intere);
     _entidades.SubmitChanges();
     return(intere.Clave);
 }
Beispiel #17
0
 private void botonGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if ((int)txtCveCliente.EditValue == 0)
         {
             Referencia refe = new Referencia
             {
                 Nombre    = txtNombre.Text,
                 Direccion = txtDireccion.Text,
                 Poblacion = txtPoblacion.Text,
                 Telefono  = txtTelefono.Text,
                 Celular   = txtCelular.Text
             };
             _entidades.Referencias.InsertOnSubmit(refe);
             _entidades.SubmitChanges();
             txtCveCliente.EditValue = refe.CveReferencia;
             EventDevolverClave(refe.CveReferencia);
         }
         else
         {
             Referencia refe = _entidades.Referencias.Single(cl => cl.CveReferencia == (int)txtCveCliente.EditValue);
             refe.Nombre    = txtNombre.Text;
             refe.Direccion = txtDireccion.Text;
             refe.Poblacion = txtPoblacion.Text;
             refe.Telefono  = txtTelefono.Text;
             refe.Celular   = txtCelular.Text;
             _entidades.SubmitChanges();
             EventDevolverClave(refe.CveReferencia);
         }
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ocurrio un error al intentar Guardar la referencia \n" + ex, "Error al guardar");
     }
 }
        public int AgregarDesempeño(Desempeño des)
        {
            if (des.FolioBoleta == string.Empty)
            {
                throw new ValidationException("Selecione la boleta a Desempeñar");
            }
            if (des.TotalPagar == 0)
            {
                throw new ValidationException("El Monto a pagar no puede ser cero");
            }
            _entidades.Desempeños.InsertOnSubmit(des);
            Boleta bol = _entidades.Boletas.First(b => b.Folio == des.FolioBoleta);

            bol.EstadoBoleta = "Desempeñado";
            bol.Pagado       = true;
            _entidades.SubmitChanges();
            return(des.Clave);
        }
Beispiel #19
0
        private void btnAbrirCerrar_Click(object sender, EventArgs e)
        {
            _entidades.Connection.ConnectionString = new clsConeccionDB().StringConn();
            SacarTransacciones();
            switch (MessageBox.Show("Esta por hacer corte de caja, \nuna vez hecho el corte ya no podra usar el sistema hasta mañana", "Corte de Caja", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
            {
            case DialogResult.Yes:
                Caja cajadc = _entidades.Cajas.Single(c => c.FechaCajaAbierto == DateTime.Today.Date);
                _entidades.Connection.ConnectionString = new clsConeccionDB().StringConn();
                SacarTransacciones();

                cajadc.CajeroCerro              = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IDUsuarioApp"));
                cajadc.FechaCajaCierre          = DateTime.Today;
                cajadc.Desempenios              = (decimal)txtDesempeños.EditValue;
                cajadc.InteresCobrados          = (decimal)txtIntereses.EditValue;
                cajadc.TotalEmpenios            = (decimal)txtEmpenios.EditValue;
                cajadc.TotalRetiros             = (decimal)txtRetiros.EditValue;
                cajadc.TotalDepositos           = (decimal)txtDepositos.EditValue;
                cajadc.TotalCompras             = (decimal)txtCompras.EditValue;
                cajadc.TotalVentas              = (decimal)txtVentas.EditValue;
                cajadc.TotalPagosVentas         = (decimal)txtAbonos.EditValue;
                cajadc.TotalFinanciamientos     = (decimal)txtFinanciamientos.EditValue;
                cajadc.TotalEnganche            = (decimal)txtEnganche.EditValue;
                cajadc.TotalPagosFinanciamiento = (decimal)txtPagosFinanciamiento.EditValue;
                cajadc.CajaFinal = (decimal)txtCajaFinal.EditValue;
                cajadc.Estado    = false;
                _entidades.SubmitChanges();
                XrptCajaDiaria caja = new XrptCajaDiaria();
                caja.DatosInforme.DataSource           = cajadc;
                caja.Parameters["Sucursal"].Value      = new clsModificarConfiguracion().configGetValue("Empresa");;
                caja.Parameters["Direccion"].Value     = new clsModificarConfiguracion().configGetValue("Direccion");;
                caja.Parameters["Cancelaciones"].Value = txtCancelaciones.EditValue;
                caja.ShowPreviewDialog();
                break;

            case DialogResult.No:
                MessageBox.Show("Caja sigue Abierta", "SoftEmpeños");
                break;
            }
        }
Beispiel #20
0
 public int AgregarAbono(PagosVenta pagosVenta)
 {
     if (pagosVenta.CveVenta == 0)
     {
         throw new ValidationException("Busque la venta que le quiere hacer abono");
     }
     if (pagosVenta.Abono == 0)
     {
         throw new ValidationException("Indique el monto a abonar");
     }
     if (pagosVenta.Saldo < 0)
     {
         throw new ValidationException("No puede abonar mas que el saldo");
     }
     if (pagosVenta.Saldo < 0)
     {
         throw new ValidationException("No puede abonar mas de lo que se debe");
     }
     _entidades.PagosVentas.InsertOnSubmit(pagosVenta);
     _entidades.SubmitChanges();
     return(pagosVenta.Clave);
 }
        private void botonGuardar_Click(object sender, EventArgs e)
        {
            if ((decimal)txtTotalAPagar.EditValue <= 0)
            {
                return;
            }
            if (!ClsVerificarCaja.CajaEstado())
            {
                MessageBox.Show("La Caja del Dia de hoy ya se ha cerrado\n SISTEMA BLOQUEADO", "Caja Cerrada",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            if (!_guardado)
            {
                if ((int)txtCveCredito.EditValue == 0)
                {
                    MessageBox.Show("Busque Primero el financiamiento para poder cobrar", Application.ProductName);
                    return;
                }
                decimal totalcantidad = 0;
                if (_dTpagos.Rows.Count > 0)
                {
                    //if para saber si va a cobrar pagos de interes y moratorios
                    for (int i = 0; i < _dTpagos.Rows.Count; i++)
                    {
                        if ((bool)_dTpagos.Rows[i]["Pagar"] == false)
                        {
                            continue;
                        }
                        FinancieraPago pagFin = new FinancieraPago()
                        {
                            FechaPago  = dtpFechaPago.DateTime.Date,
                            CveCredito = Convert.ToInt32(txtCveCredito.EditValue),
                            Pago       = (decimal)_dTpagos.Rows[i]["Pago"],
                            Recargo    = (decimal)_dTpagos.Rows[i]["Recargo"],
                            TotalPago  = Convert.ToDecimal(_dTpagos.Rows[i]["TotalAPagar"]),
                            CveUsuario =
                                Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IdUsuarioApp")),
                            Estado = true
                        };


                        totalcantidad += (decimal)_dTpagos.Rows[i]["Pago"];
                        _entidades.FinancieraPagos.InsertOnSubmit(pagFin);
                        _entidades.SubmitChanges();
                        ActualizarCredito(pagFin.Pago);

                        _folios  += pagFin.Clave + "; ";
                        _guardado = true;
                    }
                    FinancieraCredito credito =
                        _entidades.FinancieraCreditos.Single(c => c.Clave == Convert.ToInt32(txtCveCredito.EditValue));
                    txtLetrasRestantes.EditValue = credito.NumeroPlazos - credito.FinancieraPagos.Count(c => c.Estado);
                }

                new ManejadorControles().DesectivarTextBox(gpoContenedor, true);
                MessageBox.Show("Pagos Registrado", Application.ProductName);
                // ModificarSaldoFinanciamiento(_cveFinanciamiento, (totalcantidad + Convert.ToDecimal(txtAbonoCapital.EditValue)));
                ImprimirTicketPago();
            }
            else
            {
                ImprimirTicketPago();
            }
            SendKeys.Send("{TAB}");
        }
        private void CancelarDesempeño()
        {
            Desempeño entity = (from de in _entidades.Desempeños
                                where de.Clave == Convert.ToInt32(grvDatos.GetFocusedRowCellDisplayText("Clave"))
                                select de).Single();

            if (MessageBox.Show(String.Format("Si Cancela el desempeño la boleta quedara Vigente \n SE CANCELARA EL DESEMPEÑO {0}\nConfirme Cancelacion", grvDatos.GetFocusedRowCellDisplayText("Clave")), "Confirmar Cancelacion", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                Boleta boletas = _entidades.Boletas.First(bol => bol.Folio == grvDatos.GetFocusedRowCellDisplayText("FolioBoleta"));
                boletas.EstadoBoleta = "Vigente";
                boletas.Pagado       = false;
                entity.Estado        = false;
                _entidades.SubmitChanges();
                Insertarcancelacion("Desempeño", grvDatos.GetFocusedRowCellDisplayText("Clave"));
            }
        }
        private void GuardarFinanciamiento()
        {
            try
            {
                if ((int)txtClaveH.EditValue == 0)
                {
                    Financiamiento finaH = new Financiamiento
                    {
                        Tipo        = "Hipotecario",
                        Interes     = Convert.ToDecimal(txtInteresH.EditValue),
                        Prorroga    = Convert.ToInt32(txtProrrogaH.EditValue),
                        Recargo     = Convert.ToDecimal(txtRecargoH.EditValue),
                        Vencimiento = Convert.ToInt32(txtVencimientoH.EditValue)
                    };
                    _entidades.Financiamientos.InsertOnSubmit(finaH);
                    txtClaveH.EditValue = finaH.Clave;
                }
                else
                {
                    Financiamiento finaH = _entidades.Financiamientos.FirstOrDefault(f => f.Clave == Convert.ToInt32(txtClaveH.EditValue));
                    if (finaH != null)
                    {
                        finaH.Interes     = Convert.ToDecimal(txtInteresH.EditValue);
                        finaH.Prorroga    = Convert.ToInt32(txtProrrogaH.EditValue);
                        finaH.Recargo     = Convert.ToDecimal(txtRecargoH.EditValue);
                        finaH.Vencimiento = Convert.ToInt32(txtVencimientoH.EditValue);
                    }
                }
                if ((int)txtClaveA.EditValue == 0)
                {
                    Financiamiento finaA = new Financiamiento
                    {
                        Tipo        = "AutoFinanciamiento",
                        Interes     = Convert.ToDecimal(txtInteresA.EditValue),
                        Prorroga    = Convert.ToInt32(txtProrrogaA.EditValue),
                        Recargo     = Convert.ToDecimal(txtRecargoA.EditValue),
                        Enganche    = Convert.ToDecimal(txtEngancheA.EditValue),
                        Vencimiento = Convert.ToInt32(txtVencimientoA.EditValue)
                    };
                    _entidades.Financiamientos.InsertOnSubmit(finaA);
                    txtClaveA.EditValue = finaA.Clave;
                }
                else
                {
                    Financiamiento finaA = _entidades.Financiamientos.FirstOrDefault(f => f.Clave == Convert.ToInt32(txtClaveA.EditValue));
                    if (finaA != null)
                    {
                        finaA.Interes     = Convert.ToDecimal(txtInteresA.EditValue);
                        finaA.Prorroga    = Convert.ToInt32(txtProrrogaA.EditValue);
                        finaA.Recargo     = Convert.ToDecimal(txtRecargoA.EditValue);
                        finaA.Enganche    = Convert.ToDecimal(txtEngancheA.EditValue);
                        finaA.Vencimiento = Convert.ToInt32(txtVencimientoA.EditValue);
                    }
                }
                if ((int)txtClaveP.EditValue == 0)
                {
                    Financiamiento finaP = new Financiamiento
                    {
                        Tipo        = "Personal",
                        Interes     = Convert.ToDecimal(txtInteresP.EditValue),
                        Prorroga    = Convert.ToInt32(txtProrrogaP.EditValue),
                        Recargo     = Convert.ToDecimal(txtRecargoP.EditValue),
                        Vencimiento = Convert.ToInt32(txtVencimientoP.EditValue)
                    };
                    _entidades.Financiamientos.InsertOnSubmit(finaP);
                    txtClaveP.EditValue = finaP.Clave;
                }
                else
                {
                    Financiamiento finaP = _entidades.Financiamientos.FirstOrDefault(f => f.Clave == Convert.ToInt32(txtClaveP.EditValue));

                    if (finaP != null)
                    {
                        finaP.Interes     = Convert.ToDecimal(txtInteresP.EditValue);
                        finaP.Prorroga    = Convert.ToInt32(txtProrrogaP.EditValue);
                        finaP.Recargo     = Convert.ToDecimal(txtRecargoP.EditValue);
                        finaP.Vencimiento = Convert.ToInt32(txtVencimientoP.EditValue);
                    }
                }
                if ((int)txtClavePF.EditValue == 0)
                {
                    Financiamiento finaP = new Financiamiento
                    {
                        Tipo        = "Personal Fijo",
                        Interes     = Convert.ToDecimal(txtInteresPF.EditValue),
                        Prorroga    = Convert.ToInt32(txtProrrogaPF.EditValue),
                        Recargo     = Convert.ToDecimal(txtRecargoPF.EditValue),
                        Vencimiento = Convert.ToInt32(txtVencimientoPF.EditValue)
                    };
                    _entidades.Financiamientos.InsertOnSubmit(finaP);
                    txtClavePF.EditValue = finaP.Clave;
                }
                else
                {
                    Financiamiento finaP = _entidades.Financiamientos.FirstOrDefault(f => f.Clave == Convert.ToInt32(txtClavePF.EditValue));

                    if (finaP != null)
                    {
                        finaP.Interes     = Convert.ToDecimal(txtInteresPF.EditValue);
                        finaP.Prorroga    = Convert.ToInt32(txtProrrogaPF.EditValue);
                        finaP.Recargo     = Convert.ToDecimal(txtRecargoPF.EditValue);
                        finaP.Vencimiento = Convert.ToInt32(txtVencimientoPF.EditValue);
                    }
                }
                if ((int)txtClaveG.EditValue == 0)
                {
                    Financiamiento finaG = new Financiamiento
                    {
                        Tipo        = "Grupal",
                        Interes     = Convert.ToDecimal(txtInteresG.EditValue),
                        Prorroga    = Convert.ToInt32(txtProrrogaG.EditValue),
                        Recargo     = Convert.ToDecimal(txtRecargoG.EditValue),
                        Vencimiento = Convert.ToInt32(txtVencimientoG.EditValue),
                        Enganche    = Convert.ToDecimal(txtBaseG.EditValue)
                    };
                    _entidades.Financiamientos.InsertOnSubmit(finaG);
                    txtClaveG.EditValue = finaG.Clave;
                }
                else
                {
                    Financiamiento finaG = _entidades.Financiamientos.FirstOrDefault(f => f.Clave == Convert.ToInt32(txtClaveG.EditValue));

                    if (finaG != null)
                    {
                        finaG.Interes     = Convert.ToDecimal(txtInteresG.EditValue);
                        finaG.Prorroga    = Convert.ToInt32(txtProrrogaG.EditValue);
                        finaG.Recargo     = Convert.ToDecimal(txtRecargoG.EditValue);
                        finaG.Vencimiento = Convert.ToInt32(txtVencimientoG.EditValue);
                        finaG.Enganche    = Convert.ToDecimal(txtBaseG.EditValue);
                    }
                }
                _entidades.SubmitChanges();
                XtraMessageBox.Show("Ya se ha guardado la Configuracion de financiamiento", "Datos Guardados");
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message);
            }
        }
        private void botonGuardar_Click(object sender, EventArgs e)
        {
            if ((decimal)txtTotalAPagar.EditValue <= 0)
            {
                return;
            }
            if (!ClsVerificarCaja.CajaEstado())
            {
                MessageBox.Show("La Caja del Dia de hoy ya se ha cerrado\n SISTEMA BLOQUEADO", "Caja Cerrada", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            if (!_guardado)
            {
                if ((int)txtFolioFinanciamiento.EditValue == 0)
                {
                    MessageBox.Show("Busque Primero el financiamiento para poder cobrar", Application.ProductName);
                    return;
                }
                decimal totalcantidad = 0;
                if (_dtCalendario.Rows.Count > 0)
                {
                    //if para saber si va a cobrar pagos de interes y moratorios
                    for (int i = 0; i < _dtCalendario.Rows.Count; i++)
                    {
                        if ((bool)_dtCalendario.Rows[i]["Pagar"] == false)
                        {
                            continue;
                        }
                        PagosFinanciamiento pagFin = new PagosFinanciamiento()
                        {
                            FechaPago     = dtpFechaPago.DateTime.Date,
                            CvePrestamo   = _cveFinanciamiento,
                            Cantidad      = (decimal)_dtCalendario.Rows[i]["Cantidad"],
                            Interes       = (decimal)_dtCalendario.Rows[i]["Interes"],
                            Recargo       = (decimal)_dtCalendario.Rows[i]["Recargo"],
                            AbonoPrestamo =
                                (i == _dtCalendario.Rows.Count - 1) ? (decimal)txtAbonoCapital.EditValue : 0,
                            //TotalPago =
                            //    (i == _dtCalendario.Rows.Count - 1 && !chkSaldarFinanciamiento.Checked )
                            //        ? ((decimal) _dtCalendario.Rows[i]["TotalAPagar"] +
                            //           Convert.ToDecimal(txtAbonoCapital.EditValue))
                            //        : (decimal) _dtCalendario.Rows[i]["TotalAPagar"],
                            CveUsuario =
                                Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IdUsuarioApp")),
                            Estado = true
                        };
                        pagFin.TotalPago = pagFin.AbonoPrestamo + pagFin.Cantidad + pagFin.Interes + pagFin.Recargo;

                        totalcantidad += (decimal)_dtCalendario.Rows[i]["Cantidad"];
                        _entidades.PagosFinanciamientos.InsertOnSubmit(pagFin);
                        _entidades.SubmitChanges();
                        _folios  += pagFin.Clave + "; ";
                        _guardado = true;
                    }
                }
                else
                {
                    //de lo contrario ya hizo todos los pagos de interes y solo falta que liquide el capital
                    PagosFinanciamiento pagFin = new PagosFinanciamiento
                    {
                        FechaPago     = dtpFechaPago.DateTime.Date,
                        CvePrestamo   = _cveFinanciamiento,
                        Cantidad      = 0,
                        Interes       = 0,
                        Recargo       = 0,
                        AbonoPrestamo = (decimal)txtAbonoCapital.EditValue,
                        TotalPago     = (decimal)txtAbonoCapital.EditValue,
                        CveUsuario    = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IdUsuarioApp")),
                        Estado        = true
                    };
                    _entidades.PagosFinanciamientos.InsertOnSubmit(pagFin);
                    _entidades.SubmitChanges();
                    _guardado = true;
                }
                new ManejadorControles().DesectivarTextBox(gpoContenedor, true);
                MessageBox.Show("Pagos Registrado", Application.ProductName);
                ModificarSaldoFinanciamiento(_cveFinanciamiento, (totalcantidad + Convert.ToDecimal(txtAbonoCapital.EditValue)));
                ImprimirTicketPago();
            }
            else
            {
                ImprimirTicketPago();
            }
            SendKeys.Send("{TAB}");
        }
Beispiel #25
0
 public void Guardar()
 {
     //if (!ChecarCantidad())
     //    return;
     if ((int)txtCveGrupo.EditValue == 0)
     {
         FinancieraGrupo grupo = new FinancieraGrupo()
         {
             Nombre            = txtNombreGrupo.Text,
             Estado            = "PROCESO",
             FechaModificacion = DateTime.Today,
             CveUsuario        = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IdUsuarioApp")),
         };
         txtCveGrupo.EditValue = new LogicaGrupos().AgregarGrupo(grupo);
         foreach (DataRow fila in dtIntegrantesGrupo.Rows)
         {
             FinancieraGruposDetalle detGrupo = new FinancieraGruposDetalle()
             {
                 CveGrupo          = Convert.ToInt32(txtCveGrupo.EditValue),
                 CveCliente        = Convert.ToInt32(fila[0]),
                 Solicitado        = Convert.ToDecimal(fila[2]),
                 Aprobado          = 0M,
                 Base              = 0M,
                 Tipo              = fila[5].ToString(),
                 FechaModificacion = DateTime.Today.Date,
             };
             new LogicaGrupos().AgregarIntegranteGrupo(detGrupo);
         }
         cboEstado.Text = "PROCESO";
     }
     else
     {
         FinancieraGrupo grupomod = _entidades.FinancieraGrupos.First(g => g.Clave == Convert.ToInt32(txtCveGrupo.EditValue));
         //FinancieraGrupo grupo = new FinancieraGrupo()
         //{
         //    Clave = grupomod.Clave,
         //    Nombre = txtNombreGrupo.Text,
         //    Estado = cboEstado.Text,
         //    FechaModificacion = DateTime.Today,
         //    CveUsuario = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IdUsuarioApp")),
         //};
         //new LogicaGrupos().ActualizarGrupo(grupo, grupomod);
         grupomod.Nombre     = txtNombreGrupo.Text;
         grupomod.Estado     = cboEstado.Text;
         grupomod.CveUsuario = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IdUsuarioApp"));
         _entidades.SubmitChanges();
         new LogicaGrupos().EliminarDetalles(grupomod.Clave);
         foreach (DataRow fila in dtIntegrantesGrupo.Rows)
         {
             FinancieraGruposDetalle detGrupo = new FinancieraGruposDetalle()
             {
                 CveGrupo          = Convert.ToInt32(txtCveGrupo.EditValue),
                 CveCliente        = Convert.ToInt32(fila[0]),
                 Solicitado        = Convert.ToDecimal(fila[2]),
                 Aprobado          = Convert.ToDecimal(fila[3]),
                 Base              = Convert.ToDecimal(fila[4]),
                 Tipo              = fila[5].ToString(),
                 FechaModificacion = DateTime.Today.Date,
             };
             new LogicaGrupos().AgregarIntegranteGrupo(detGrupo);
         }
         if (grvIntegrantes.Columns["Base"].Visible)
         {
             btnImprimirDeposito.Enabled = true;
         }
     }
     btnImprimirSocioEconomico.Enabled = true;
 }
        private void ImprimirRetiroBase()
        {
            Transaccione tran = new Transaccione
            {
                CveUsuario       = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IDUsuarioAPP")),
                FechaTransaccion = DateTime.Today.Date,
                TipoTransaccion  = "Retiro",
                Cantidad         = Convert.ToDecimal(txtBase.EditValue),
                Concepto         = string.Format("RETIRO DE BASE DEL GRUPO {0}-{1} POR SALDAR CRÉDITO", txtCveGrupo.Text, txtNombreGrupo.Text),
                Estado           = true
            };
            EmpeñosDC _enti = new EmpeñosDC(new clsConeccionDB().StringConn());

            _enti.Transacciones.InsertOnSubmit(tran);
            _enti.SubmitChanges();
            //new LogicaTransacciones().AgregarTransaccion(tran);//se comento 4/6/2014 por que usuario normal no tiene permiso de los retiros
            Configuracione empre = new EmpeñosDC(new clsConeccionDB().StringConn()).Configuraciones.First();

            string empresa     = new clsModificarConfiguracion().configGetValue("Empresa");
            string razonSocial = new clsModificarConfiguracion().configGetValue("RazonSocial");
            string rfc         = new clsModificarConfiguracion().configGetValue("RFC");
            string curp        = new clsModificarConfiguracion().configGetValue("CURP");
            string dirc        = String.Format("{0} CP {1} {2}", empre.Direccion, empre.CodigoPostal, empre.Municipio);

            int padRe    = ((40 - empresa.Length) / 2) + empresa.Length;
            int padRrs   = ((40 - razonSocial.Length) / 2) + razonSocial.Length;
            int padRrfc  = ((40 - rfc.Length) / 2) + rfc.Length;
            int padRcurp = ((40 - curp.Length) / 2) + curp.Length;


            Ticket ticket = new Ticket(2);

            ticket.AddHeaderLine("            CASA  DE  EMPEÑOS           ");
            ticket.AddHeaderLine("                                        ");
            ticket.AddHeaderLine(empresa.PadLeft(padRe));
            ticket.AddHeaderLine(razonSocial.PadLeft(padRrs));
            ticket.AddHeaderLine(rfc.PadLeft(padRrfc));
            ticket.AddHeaderLine(curp.PadLeft(padRcurp));
            if (dirc.Length > 40)
            {
                int currentChar = 0;
                int itemLenght  = dirc.Length;

                while (itemLenght > 40)
                {
                    ticket.AddHeaderLine(dirc.Substring(currentChar, 40));
                    currentChar += 40;
                    itemLenght  -= 40;
                }
                ticket.AddHeaderLine(dirc.Substring(currentChar));
            }
            else
            {
                ticket.AddHeaderLine(dirc);
            }
            ticket.AddHeaderLine("           TICKET DE RETIRO");

            ticket.AddSubHeaderLine("CLAVE: " + tran.Clave);
            ticket.AddSubHeaderLine("REALIZO: " + new clsModificarConfiguracion().configGetValue("UsuarioAPP"));
            ticket.AddSubHeaderLine(String.Format("FECHA: {0} {1}", DateTime.Today.ToString("dd/MMM/yyyy").ToUpper(), DateTime.Now.ToShortTimeString()));
            string[] lineas = tran.Concepto.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var linea in lineas)
            {
                ticket.AddItem("", linea, "");
            }
            //ticket.AddItem("", txtConcepto.Text, "");
            ticket.AddTotal("CANTIDAD:", tran.Cantidad.ToString("$ #,##0.00"));
            ticket.AddFooterLine("");
            ticket.AddFooterLine("");
            ticket.AddFooterLine("________________________________________");
            ticket.AddFooterLine("                AUTORIZO                ");
            ticket.AddFooterLine("");
            ticket.AddFooterLine("");
            ticket.AddFooterLine("");

            ticket.PrintTicket(new clsModificarConfiguracion().configGetValue("ImpresoraTickets"));
        }
        private void AbrirCaja()
        {
            _entidades.Connection.ConnectionString = new clsConeccionDB().StringConn();
            var cajadc = (from cj in  _entidades.Cajas
                          select cj).OrderByDescending(cj => cj.FechaCajaAbierto).FirstOrDefault();

            if (cajadc == null)
            {
                MessageBox.Show("La caja se iniciara con $ 0.00 pesos,\n realice un deposito para poder realizar empeños y compras", "No hay dinero en caja");
                AbrirCaja(0);
            }
            else
            {
                if (cajadc.Estado == false && cajadc.FechaCajaAbierto <= DateTime.Today.Date.AddDays(-1))
                {
                    AbrirCaja(cajadc.CajaFinal);
                }
                else if (cajadc.Estado && cajadc.FechaCajaAbierto < DateTime.Today)
                {
                    MessageBox.Show("Se procedera a cerrar la caja anterior y abrir el del dia de hoy");

                    var com = (_entidades.Compras.Where(
                                   c => c.FechaCompra == cajadc.FechaCajaAbierto && cajadc.Estado).Select(c => (decimal?)c.TotalCompra)).Sum() ?? 0;
                    var empe = (from e in _entidades.Boletas
                                where e.FechaPrestamo == cajadc.FechaCajaAbierto && e.EstadoBoleta != "Cancelado"
                                select(decimal?) e.Prestamo).Sum() ?? 0;
                    var inte = (from i in _entidades.PagosInteres
                                where i.FechaPago == cajadc.FechaCajaAbierto && i.Estado
                                select(decimal?) i.TotalPagar).Sum() ?? 0;
                    var desem = (from d in _entidades.Desempeños
                                 where d.FechaDesempeño == cajadc.FechaCajaAbierto && d.Estado
                                 select(decimal?) d.TotalPagar).Sum() ?? 0; var ret = (from r in _entidades.Transacciones
                                                                                       where r.FechaTransaccion == cajadc.FechaCajaAbierto && r.TipoTransaccion == "Retiro" && r.Estado
                                                                                       select(decimal?) r.Cantidad).Sum() ?? 0;
                    var dep = (from depo in _entidades.Transacciones
                               where depo.FechaTransaccion == cajadc.FechaCajaAbierto && (depo.TipoTransaccion == "Deposito" || depo.TipoTransaccion == "Base") && depo.Estado               //DateTime.Now
                               select(decimal?) depo.Cantidad).Sum() ?? 0;
                    decimal ventas = (from vc in _entidades.Ventas
                                      where vc.Estado == "Pagado" && vc.FechaVenta == cajadc.FechaCajaAbierto
                                      select(decimal?) vc.TotalVenta).Sum() ?? 0;
                    decimal apartados = (from vc in _entidades.Ventas
                                         where vc.Estado == "Apartado" && vc.FechaVenta == cajadc.FechaCajaAbierto
                                         select(decimal?) vc.Enganche).Sum() ?? 0;
                    decimal abonos = (_entidades.PagosVentas.Where(
                                          abo => abo.Estado && abo.FechaPago == cajadc.FechaCajaAbierto).Select(abo => (decimal?)abo.Abono)).Sum() ?? 0;
                    decimal pagoF = (from pf in _entidades.PagosFinanciamientos
                                     where pf.Estado && pf.FechaPago.Date == cajadc.FechaCajaAbierto
                                     select(decimal?) pf.TotalPago).Sum() ?? 0;
                    decimal finan = (from pf in _entidades.Prestamos
                                     where pf.Estado != "Cancelado" && pf.FechaPrestamo.Date == cajadc.FechaCajaAbierto
                                     select(decimal?) pf.Cantidad).Sum() ?? 0;
                    decimal creditos = (from pf in _entidades.FinancieraCreditos
                                        where pf.Estado == "Activo" && pf.FechaInicio.Date == cajadc.FechaCajaAbierto
                                        select(decimal?) pf.Prestamo).Sum() ?? 0;
                    decimal pagCre = (from pf in _entidades.FinancieraPagos
                                      where pf.Estado && pf.FechaPago.Date == cajadc.FechaCajaAbierto
                                      select(decimal?) pf.TotalPago).Sum() ?? 0;

                    decimal engan = (from pf in _entidades.Prestamos
                                     where pf.Estado != "Cancelado" && pf.FechaPrestamo.Date == cajadc.FechaCajaAbierto
                                     select(decimal?) pf.Enganche).Sum() ?? 0;

                    //decimal dtpFechaCaja= DateTime.Today.Date;

                    //var cajadc = (_mapeoCasaEmpenios.Cajas.Where(c => c.FechaCajaAbierto == cajadc.FechaCajaAbierto)).First();
                    cajadc.CajeroCerro              = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IDUsuarioApp"));
                    cajadc.FechaCajaCierre          = DateTime.Today;
                    cajadc.Desempenios              = desem;
                    cajadc.InteresCobrados          = inte;
                    cajadc.TotalEmpenios            = empe;
                    cajadc.TotalRetiros             = ret;
                    cajadc.TotalDepositos           = dep;
                    cajadc.TotalCompras             = com;
                    cajadc.TotalVentas              = ventas + apartados;
                    cajadc.TotalPagosVentas         = abonos;
                    cajadc.TotalFinanciamientos     = finan + creditos;
                    cajadc.TotalEnganche            = engan;
                    cajadc.TotalPagosFinanciamiento = pagoF + pagCre;
                    cajadc.CajaFinal = (cajadc.CajaInicial + dep + inte + desem + ventas + apartados + abonos + engan + pagoF + pagCre) - (empe + ret + com + finan + creditos);
                    cajadc.Estado    = false;//false significa que esta abierto
                    //mapeoCasaEmpenios.CajaDC.InsertOnSubmit(cajadc);
                    _entidades.SubmitChanges();
                    AbrirCaja(cajadc.CajaFinal);
                }
                else
                {
                    Caja caj = _entidades.Cajas.Single(c => c.FechaCajaAbierto == DateTime.Today.Date);
                    if (caj.Estado == false)
                    {
                        MessageBox.Show("La Caja del Dia de hoy ya se ha cerrado\n SISTEMA BLOQUEADO", "Caja Cerrada", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Application.Exit();
                    }
                }
            }
        }