Exemple #1
0
    public DataTable PrestamoUsuario(EPrestamo ePres, String user)
    {
        string          ipAddress  = Ip.GetIP();
        string          MacAddress = Mac.GetMACAddress2();
        DataTable       Prestamo   = new DataTable();
        MySqlConnection conection  = new MySqlConnection(ConfigurationManager.ConnectionStrings["Mybd"].ConnectionString);//procede la conexion llamada "Mybd" ver web.config

        try
        {
            conection.Open();                                                                         //abre coneccion
            MySqlDataAdapter dataAdapter = new MySqlDataAdapter("sp_agregar_SolPrestamo", conection); //crea objeto para llamar el proceso almacenado
            dataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            dataAdapter.SelectCommand.Parameters.Add("_id_elemento", MySqlDbType.Int32).Value = ePres.Id_elemento;
            dataAdapter.SelectCommand.Parameters.Add("_id_usuario", MySqlDbType.Int32).Value  = ePres.Usuario_id;
            dataAdapter.SelectCommand.Parameters.Add("_Estado_id", MySqlDbType.Int32).Value   = ePres.Estado_id;
            dataAdapter.SelectCommand.Parameters.Add("_ip", MySqlDbType.VarChar, 100).Value   = ipAddress;
            dataAdapter.SelectCommand.Parameters.Add("_mac", MySqlDbType.VarChar, 100).Value  = MacAddress;
            dataAdapter.SelectCommand.Parameters.Add("_user", MySqlDbType.VarChar, 30).Value  = user;
            dataAdapter.Fill(Prestamo);
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            if (conection != null)
            {
                conection.Close();
            }
        }
        return(Prestamo);
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Select")
        {
            EPrestamo ePres = new EPrestamo();
            int       num   = Convert.ToInt32(e.CommandArgument);
            ePres.Id_elemento = Int32.Parse(((Label)GridView1.Rows[num].FindControl("Label1")).Text);
            ePres.Usuario_id  = Int32.Parse(Session["id"].ToString());
            ePres.Estado_id   = 4;
            DAPrestamo dPres = new DAPrestamo();
            String     user  = Session["nombre"].ToString();
            DataTable  tPres = dPres.PrestamoUsuario(ePres, user);

            if (tPres.Rows.Count == 2)
            {
                this.RegisterStartupScript("mensaje", ("<script type='text/javascript'>alert('Tiene el numero maximo de libros permitidos en su poder por favor devuelvalos antes del plazo indicado');</script>"));
            }
            if (tPres.Rows.Count == 3)
            {
                this.RegisterStartupScript("mensaje", ("<script type='text/javascript'>alert('Excedio el numero de libros a solicitar');</script>"));
            }
            if (tPres.Rows.Count == 1)
            {
                this.RegisterStartupScript("mensaje", ("<script type='text/javascript'>alert('No puede solicitar libros hasta que cancele todas sus deudas con la biblioteca paulo coelo');</script>"));
            }
            if (tPres.Rows.Count == 4)
            {
                this.RegisterStartupScript("mensaje", ("<script type='text/javascript'>alert('No hay mas libros de estos');</script>"));
            }
        }
    }
Exemple #3
0
    public void RegistrarPrestamo(EPrestamo ePres, String user)
    {
        string          ipAddress  = Ip.GetIP();
        string          MacAddress = Mac.GetMACAddress2();
        MySqlConnection conection  = new MySqlConnection(ConfigurationManager.ConnectionStrings["Mybd"].ConnectionString);//procede la conexion llamada "Mybd" ver web.config

        try
        {
            conection.Open();                                                          //abre coneccion
            MySqlCommand command = new MySqlCommand("sp_agregar_Prestamo", conection); //crea objeto para llamar el proceso almacenado
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("_id", MySqlDbType.Int32).Value = ePres.Id;
            command.Parameters.Add("_id_administrador", MySqlDbType.Int32).Value = ePres.Admin_id;
            command.Parameters.Add("_Estado_id", MySqlDbType.Int32).Value        = ePres.Estado_id;
            command.Parameters.Add("_ip", MySqlDbType.VarChar, 100).Value        = ipAddress;
            command.Parameters.Add("_mac", MySqlDbType.VarChar, 100).Value       = MacAddress;
            command.Parameters.Add("_user", MySqlDbType.VarChar, 30).Value       = user;
            command.ExecuteNonQuery();
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            if (conection != null)
            {
                conection.Close();
            }
        }
    }
Exemple #4
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Select")
        {
            Int32     ele   = 0;
            int       cont  = 0;
            EPrestamo ePres = new EPrestamo();
            int       num   = Convert.ToInt32(e.CommandArgument);
            ePres.Usuario_id = Int32.Parse(((Label)GridView1.Rows[num].FindControl("Label1")).Text);
            DAUsuario dUser = new DAUsuario();
            String    user  = Session["nombre"].ToString();

            DataTable delemento = new DataTable();
            delemento = dUser.SaldarMultas(ePres.Usuario_id, user);

            DAElemento dElem = new DAElemento();
            GridView1.Rows[num].Visible = false;

            for (int x = 0; x < delemento.Rows.Count; x++)
            {
                ele = Int32.Parse(delemento.Rows[x]["prs"].ToString());
                dElem.DescontarElemento(ele);
            }
        }
    }
Exemple #5
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Select")
     {
         EPrestamo ePres = new EPrestamo();
         int       num   = Convert.ToInt32(e.CommandArgument);
         ePres.Id        = Int32.Parse(((Label)GridView1.Rows[num].FindControl("L_id")).Text);
         ePres.Admin_id  = Int32.Parse(Session["id"].ToString());
         ePres.Estado_id = 1;
         DAPrestamo dPres = new DAPrestamo();
         String     user  = Session["nombre"].ToString();
         dPres.RegistrarPrestamo(ePres, user);
         GridView1.Rows[num].Visible = false;
     }
 }
Exemple #6
0
        public override void Ejecutar()
        {
            EMedioPago medioPago = new PMediosPago().GetAllMediosPago().MedioPago("1");
            Dictionary <string, string> idsAcumulados = Entorno.Instancia.IdsAcumulados;
            PPrestamo pPrestamo       = new PPrestamo();
            Respuesta respuesta       = new Respuesta();
            EPrestamo ePrestamo       = Entorno.Instancia.Prestamo;
            string    factura         = ProcesarPlantilla.Prestamos(ePrestamo);
            string    modeloImpresora = Entorno.Instancia.Impresora.Marca ?? "impresora";

            var tiempoGuardarPrestamo = new MetricaTemporizador("PrestamoAgregado");

            pPrestamo.GuardarPrestamo(Entorno.Instancia.Prestamo, ref idsAcumulados, ((int)TipoTransaccion.Prestamo).ToString(), Entorno.Instancia.Terminal, Entorno.Instancia.Usuario, medioPago, factura, modeloImpresora, out respuesta);

            //
            string idVentaPrestamo = respuesta.Mensaje;

            if (respuesta.Valida == false)
            {
                Telemetria.Instancia.AgregaMetrica(tiempoGuardarPrestamo.Para().AgregarPropiedad("Exitoso", false).AgregarPropiedad("Transaccion", (Entorno.Instancia.Terminal.NumeroUltimaTransaccion + 1)).AgregarPropiedad("Valor", (Entorno.Instancia.Prestamo.Valor)).AgregarPropiedad("Error", respuesta.Mensaje));
                throw new Exception(respuesta.Mensaje);
            }

            Telemetria.Instancia.AgregaMetrica(tiempoGuardarPrestamo.Para().AgregarPropiedad("Exitoso", true).AgregarPropiedad("Transaccion", (Entorno.Instancia.Terminal.NumeroUltimaTransaccion + 1)).AgregarPropiedad("Valor", (Entorno.Instancia.Prestamo.Valor)));

            ETerminal terminal = new PTerminal().BuscarTerminalPorCodigo(Common.Config.Terminal, out respuesta);

            if (respuesta.Valida == false)
            {
                throw new Exception(respuesta.Mensaje);
            }

            if (Entorno.Instancia.Usuario.UsuarioSupervisor != null)
            {
                PIntervencion pInterv = new PIntervencion();
                EIntervencion eInterv = new EIntervencion();

                eInterv.id_venta        = idVentaPrestamo;
                eInterv.claveSupervisor = Entorno.Instancia.Usuario.UsuarioSupervisor.ClaveSupervisor;
                eInterv.motivo          = "Intervención prestamo";
                eInterv.nro_transac     = Convert.ToInt32(Entorno.Instancia.Terminal.NumeroUltimaTransaccion + 1);

                pInterv.GuardarIntervencion(eInterv, Entorno.Instancia.Terminal, Entorno.Instancia.Usuario, out respuesta);
            }

            Entorno.Instancia.Terminal                  = terminal;
            Entorno.Instancia.Prestamo                  = null;
            Entorno.Instancia.IdsAcumulados             = idsAcumulados;
            Entorno.Instancia.Usuario.UsuarioSupervisor = null;

            iu.PanelVentas.VisorMensaje = "Prestamo registrado correctamente.";
            iu.PanelVentas.VisorEntrada = string.Empty;

            // si es panel touch
            if (Config.ViewMode == InternalSettings.ModoTouch)
            {
                Entorno.Instancia.Vista.PanelVentas.LimpiarOperacion();
            }


            log.Info("[CmdGuardarPrestamo] Prestamo registrado correctamente.");

            // Imprimir
            Entorno.Instancia.Impresora.Imprimir(factura, true, false);

            log.Info("[CmdAgregarPrestamo] Imprimir Operación: " + factura);
            ePrestamo = null;

            if (Config.ViewMode == InternalSettings.ModoConsola)
            {
                iu.PanelPrestamos.VisorEntrada = string.Empty;
            }

            Solicitudes.SolicitudPanelVenta volver = new Solicitudes.SolicitudPanelVenta(Enums.Solicitud.Vender);
            Reactor.Instancia.Procesar(volver);

            iu.MostrarPanelVenta();
        }
Exemple #7
0
        public void GuardarPrestamo(EPrestamo prestamo, ref Dictionary <string, string> IdsAcumulados, string tipo, ETerminal terminal, EUsuario usuario, EMedioPago medioPago, string contenido, string modeloImpresora, out Respuesta respuesta)
        {
            //1. Creamos el encabezado de la venta.
            string    idPrestamo = Guid.NewGuid().ToString();
            RPrestamo rPrestamo  = new RPrestamo();

            respuesta = new Respuesta(false);

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    if (rPrestamo.CrearPrestamo(idPrestamo, prestamo.Valor, terminal.Codigo, tipo, 1, (long)terminal.NumeroUltimaTransaccion + 1, terminal.Prefijo, usuario.IdUsuario) == 1)
                    {
                        //3. Creamos totales de venta(registro_venta).
                        if (IdsAcumulados == null)
                        {
                            IdsAcumulados = new Dictionary <string, string>();
                            IdsAcumulados.Add("idRegistroVenta", Guid.NewGuid().ToString());
                            //Creamos el registro venta
                            rPrestamo.CrearRegistroVenta(IdsAcumulados["idRegistroVenta"], terminal.Codigo, usuario.IdUsuario);
                        }
                        //Actualizo registro venta
                        rPrestamo.ActualizarRegistroVenta(IdsAcumulados["idRegistroVenta"], prestamo.Valor);

                        rPrestamo.CrearMedioPago(medioPago.Codigo, terminal.Codigo, (long)terminal.NumeroUltimaTransaccion + 1, prestamo.Valor, idPrestamo);
                        rVenta.ActualizarTerminal(terminal.Codigo, (long)terminal.NumeroUltimaFactura, (long)terminal.NumeroUltimaTransaccion + 1);

                        rVenta.CrearCopiaImpresion("00", terminal.Localidad.Codigo, terminal.Codigo, tipo, usuario.IdUsuario, contenido, terminal.Localidad.Codigo, modeloImpresora, (long)terminal.NumeroUltimaFactura, (int)terminal.NumeroUltimaTransaccion + 1, terminal.Prefijo, terminal.Codigo, tipo, usuario.IdUsuario);
                        respuesta.Valida  = true;
                        respuesta.Mensaje = idPrestamo;
                    }
                    else
                    {
                        throw new Exception("[GuardarPrestamo]: Transaccion no pudo ser guardada.");
                    }
                    scope.Complete();
                }
            }
            catch (SqlException e)
            {
                if (e.Number == -2 || e.Number == 121)
                {
                    respuesta.Valida  = false;
                    respuesta.Mensaje = "Se perdió la conexión con el servidor.";
                    log.Error("[GuardarPrestamo]: No pudo ser guardada la transaccion: " + e.Message);
                }
                else
                {
                    respuesta.Valida  = false;
                    respuesta.Mensaje = "Hubo un problema al momento de guardar la transaccion. Por favor contacte al administrador del sistema.";
                    log.Error("[GuardarPrestamo]: No pudo ser guardada la transaccion: " + e.Message);
                }
                Telemetria.Instancia.AgregaMetrica(new Excepcion(e));
            }
            catch (Exception ex)
            {
                respuesta.Documentar(false, "No pudo ser guardado el prestamo.");
                log.Error("[GuardarPrestamo]: No pudo ser guardada el prestamo. " + ex);
                Telemetria.Instancia.AgregaMetrica(new Excepcion(ex));
            }
        }
Exemple #8
0
        public static void GenerarTransaccionApertura()
        {
            try
            {
                bool generaTransAperturaCajon = Entorno.Instancia.Parametros.ObtenerValorParametro <bool>("pdv.imprime_transaccion_abrir_cajon");

                // ¿debe generar transacción?
                if (!generaTransAperturaCajon)
                {
                    return;
                }

                string motivoIntervencion = string.Empty;

                if (Entorno.Instancia.Recogida != null)
                {
                    ERecogida recogidaActual = Entorno.Instancia.Recogida;
                    if (recogidaActual != null)
                    {
                        if (recogidaActual.listRecogidas.Count > 0 && recogidaActual.Valor > 0)
                        {
                            return;
                        }
                    }

                    motivoIntervencion = "Intervención Recogida";
                }
                else if (Entorno.Instancia.Prestamo != null)
                {
                    EPrestamo prestamoActual = Entorno.Instancia.Prestamo;
                    if (prestamoActual != null)
                    {
                        if (prestamoActual.ListPrestamos.Count > 0 && prestamoActual.Valor > 0)
                        {
                            return;
                        }
                    }

                    motivoIntervencion = "Intervención Prestamo";
                }

                //
                log.Info("[GenerarTransaccionApertura] Guardando transacción apertura cajón ...");
                PCajon pCajon = new PCajon();
                Dictionary <string, string> idsAcumulados = Entorno.Instancia.IdsAcumulados;

                // Generar tirilla de apertura de cajón
                Respuesta respuesta = new Respuesta();
                string    factura   = ProcesarPlantilla.AperturaCajon();

                var tiempoGuardarAperturaCajon = new MetricaTemporizador("AperturaCajon");
                pCajon.GuardarAperturaCajon(ref idsAcumulados, ((int)TipoTransaccion.AbrirCajon).ToString(), Entorno.Instancia.Terminal, Entorno.Instancia.Usuario, factura ?? "contenido", out respuesta);
                string idVentaApertCajon = respuesta.Mensaje;

                if (!respuesta.Valida)
                {
                    Telemetria.Instancia.AgregaMetrica(tiempoGuardarAperturaCajon.Para().AgregarPropiedad("Exitoso", false).AgregarPropiedad("Transaccion", (Entorno.Instancia.Terminal.NumeroUltimaTransaccion + 1)).AgregarPropiedad("Error", respuesta.Mensaje));
                }
                else
                {
                    Telemetria.Instancia.AgregaMetrica(tiempoGuardarAperturaCajon.Para().AgregarPropiedad("Exitoso", true).AgregarPropiedad("Transaccion", (Entorno.Instancia.Terminal.NumeroUltimaTransaccion + 1)).AgregarPropiedad("CajonAbierto", respuesta.Mensaje));

                    respuesta = new Respuesta(false);

                    ETerminal terminal = new PTerminal().BuscarTerminalPorCodigo(Config.Terminal, out respuesta);
                    if (respuesta.Valida == true)
                    {
                        // guardar transacción si hubo
                        if (Entorno.Instancia.Usuario.UsuarioSupervisor != null)
                        {
                            PIntervencion pInterv = new PIntervencion();
                            EIntervencion eInterv = new EIntervencion();

                            eInterv.id_venta        = idVentaApertCajon;
                            eInterv.claveSupervisor = Entorno.Instancia.Usuario.UsuarioSupervisor.ClaveSupervisor;
                            eInterv.motivo          = motivoIntervencion;
                            eInterv.nro_transac     = Convert.ToInt32(Entorno.Instancia.Terminal.NumeroUltimaTransaccion + 1);

                            pInterv.GuardarIntervencion(eInterv, Entorno.Instancia.Terminal, Entorno.Instancia.Usuario, out respuesta);
                        }


                        Entorno.Instancia.Terminal                  = terminal;
                        Entorno.Instancia.IdsAcumulados             = idsAcumulados;
                        Entorno.Instancia.Usuario.UsuarioSupervisor = null;

                        Entorno.Instancia.Recogida = null;
                        Entorno.Instancia.Prestamo = null;

                        // Imprimir
                        Entorno.Instancia.Impresora.Imprimir(factura, cortarPapel: true, abrirCajon: false);
                        log.Info("[GenerarTransaccionApertura.AbrirCajon] Imprimir Operación: " + factura);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Info($"[GenerarTransaccionApertura] Error: {ex.Message}");
            }
        }