예제 #1
0
        private void CargarDatosColaborador()
        {
            if (Pro_Conexion.State != ConnectionState.Open)
            {
                Pro_Conexion.Open();
            }

            string       sentencia = @"SELECT * FROM arca_tesoros.ft_view_ficha_ingreso (:p_id_colaborador)";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            pgComando.Parameters.Add("p_id_colaborador", PgSqlType.Int).Value = Pro_ID_Colaborador;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    txtNombreColaborador.Text    = pgDr.GetString("nombre_colaborador");
                    txtIdentidadColaborador.Text = pgDr.GetString("numero_identidad");
                    txtFuerzasEspeciales.Text    = pgDr.GetString("area_atencion");
                    v_ruta_fotografia            = pgDr.GetString("direccion_fotografia");
                }

                pgDr.Close();
            }
            catch (Exception Exc)
            {
                Log_Excepciones.CapturadorExcepciones(Exc, this.Name, "CargarDatosColaborador");
            }
        }
예제 #2
0
        public UsuarioDTO Autentica(UsuarioDTO objUsuario)
        {
            PgSqlConnection conn = new PgSqlConnection("User Id=postgres;Password=root;host=localhost;database=NIVEL_ACESSO;");
            PgSqlCommand    cmd  = new PgSqlCommand();

            cmd.CommandText = string.Format("SELECT * FROM public.\"TRABALHADORES\" WHERE \"LOGIN\" ='{0}' AND \"SENHA\" = '{1}';", objUsuario.Login, objUsuario.Senha);
            cmd.Connection  = conn;
            conn.Open();

            int aff = cmd.ExecuteNonQuery();

            PgSqlDataReader ER;

            UsuarioDTO usuario = new UsuarioDTO();

            ER = cmd.ExecuteReader();

            if (ER.Read())
            {
                usuario.Cpf           = Convert.ToString(ER["cpf_usu"]);
                usuario.Nome          = Convert.ToString(ER["nome_usu"]);
                usuario.Email         = Convert.ToString(ER["email_usu"]);
                usuario.Login         = Convert.ToString(ER["login_usu"]);
                usuario.Senha         = Convert.ToString(ER["senha_usu"]);
                usuario.NivelDeAcesso = Convert.ToInt16(ER["nivelAcesso_usu"]);
            }



            conn.Close();

            return(usuario);
        }
예제 #3
0
        private void CargarDatos()
        {
            if (Pro_Conexion.State != ConnectionState.Open)
            {
                Pro_Conexion.Open();
            }

            string       sentencia = "SELECT * FROM area_servicio.ft_view_ultima_tasa_cambio();";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    lblVenta.Text  = pgDr.GetString("venta");
                    lblCompra.Text = pgDr.GetString("compra");
                }

                pgDr.Close();
                sentencia = null;
                pgComando.Dispose();
            }
            catch (Exception Exc)
            {
                MessageBox.Show("Algo salió mal en el momento de cargar la tasa de cambio. " + Exc.Message);
            }
        }
예제 #4
0
        public static DateTime ObtenerHoraServidor(PgSqlConnection pConexion)
        {
            DateTime v_resultado = Convert.ToDateTime(null);

            if (pConexion.State != System.Data.ConnectionState.Open)
            {
                pConexion.Open();
            }

            string       sentencia = "SELECT * FROM arca_tesoros_conf.ft_view_variables_tiempo();";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, pConexion);

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    v_resultado = pgDr.GetDateTime("fecha_hora_servidor");
                }

                pgDr.Close();

                sentencia = null;
                pgComando.Dispose();
                pgComando = null;

                return(v_resultado);
            }
            catch (Exception Exc)
            {
                Log_Excepciones.CapturadorExcepciones(Exc, "Utilidades.cs", "ObtenerHoraServidor");
                return(Convert.ToDateTime(null));
            }
        }
예제 #5
0
        public void CargarDatos()
        {
            v_lista_noticias.Clear();

            if (Pro_Conexion.State != ConnectionState.Open)
            {
                Pro_Conexion.Open();
            }

            string       sentencia = @"SELECT * FROM area_servicio.ft_view_noticias_cliente (:p_id_cliente_servicio);";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            pgComando.Parameters.Add("p_id_cliente_servicio", PgSqlType.Int).Value = Pro_ID_Cliente_Servicio;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                while (pgDr.Read())
                {
                    v_lista_noticias.Add(pgDr.GetString("texto_noticia"));
                }

                pgDr.Close();
                sentencia = null;
                pgComando.Dispose();
            }
            catch (Exception Exc)
            {
                MessageBox.Show("Algo salió mal en el momento de obtener lista de noticias. " + Exc.Message);
            }
        }
예제 #6
0
        private void cbDatabase_DropDown(object sender, System.EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            cbDatabase.Items.Clear();
            cbSchema.Text = "";

            PgSqlConnection databaseConnection = new PgSqlConnection();

            databaseConnection.Host     = cbHost.Text;
            databaseConnection.UserId   = edUser.Text;
            databaseConnection.Password = edPassword.Text;
            databaseConnection.Port     = (int)edPort.Value;

            try {
                databaseConnection.Open();
                System.Data.IDbCommand command = new PgSqlCommand("SELECT datname FROM pg_database WHERE datallowconn = true and datname <> 'template1'", databaseConnection);
                using (System.Data.IDataReader reader = command.ExecuteReader()) {
                    while (reader.Read())
                    {
                        cbDatabase.Items.Add(reader[0]);
                    }
                }
            }
            catch (Exception exception) {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally {
                Cursor.Current = Cursors.Default;
                databaseConnection.Close();
            }
        }
        private void ObtenerFusiblesIndicadores()
        {
            if (Pro_Conexion.State != ConnectionState.Open)
            {
                Pro_Conexion.Open();
            }

            string       sentencia = "SELECT * FROM arca_tesoros.ft_proc_obtiene_fusibles_indicadores();";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    v_conteo_fusible_solicitudes   = pgDr.GetInt32("conteo_solicitudes");
                    v_conteo_fusible_cumpleanieros = pgDr.GetInt32("conteo_cumpleanieros");

                    if (v_conteo_fusible_cumpleanieros == 0)
                    {
                        fusibleCumpleanios.Visible = false;
                    }
                    else
                    {
                        fusibleCumpleanios.Visible = true;
                    }
                }

                pgDr.Close();
            }
            catch (Exception Exc)
            {
            }
        }
예제 #8
0
        public List <Ventas> ObtenerListaVENTASDelDía()
        {
            List <Ventas> listpro = new List <Ventas>();


            DateTime fechaActual = DateTime.Today;

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = " SELECT * FROM ventas ORDER BY id";
                ///select *FROM ventas WHERE fecha_venta= '2015/12/12'

                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        DateTime fechaDeVenta = dr.GetDateTime("fecha_venta");
                        if (fechaDeVenta == fechaActual)
                        {
                            listpro.Add(new Ventas(dr.GetInt32("id_productos"), dr.GetInt32("cantidad"), dr.GetDecimal("precio_de_venta"), dr.GetDateTime("fecha_venta")));
                        }
                    }

                    dr.Close();
                }
            }
            return(listpro);
        }
        private void ObtenerInformacionActividad()
        {
            if (Pro_Conexion.State != ConnectionState.Open)
            {
                Pro_Conexion.Open();
            }

            string       sentencia = @"SELECT * FROM arca_tesoros.ft_view_datos_actividades (
                                                                                       :p_id_actividad
                                                                                    )";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            pgComando.Parameters.Add("p_id_actividad", PgSqlType.Int).Value = Pro_ID_Actividad;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    lblEncabezado.Text = "Lista de Asistencia para el día " + pgDr.GetDateTime("fecha").Date.ToShortDateString();
                }

                pgDr.Close();
            }
            catch (Exception Exc)
            {
                Log_Excepciones.CapturadorExcepciones(Exc, this.Name, "ObtenerInformacionActividad");
            }
        }
        private void ObtenerActividad()
        {
            if (Pro_Conexion.State != ConnectionState.Open)
            {
                Pro_Conexion.Open();
            }

            string       sentencia = @"SELECT * FROM arca_tesoros.ft_proc_obtener_actividad_del_dia (:p_id_area_atencion)";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            pgComando.Parameters.Add("p_id_area_atencion", PgSqlType.Int).Value = Pro_ID_Area_Atencion;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    Pro_ID_Actividad = pgDr.GetInt32("id_actividad");
                }
                pgDr.Close();
            }
            catch (Exception Exc)
            {
                Log_Excepciones.CapturadorExcepciones(Exc, this.Name, "ObtenerActividad");
            }
        }
예제 #11
0
        public List <Estatus> Estatus(DateTime fecha1, DateTime fecha2)
        {
            fecha1 = Convert.ToDateTime(fecha1.ToShortDateString());
            fecha2 = Convert.ToDateTime(fecha2.ToShortDateString());
            fecha1 = Convert.ToDateTime(fecha1);
            fecha2 = Convert.ToDateTime(fecha2);
            List <Estatus> lista = new List <Estatus>();

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = " select*from Modifica";

                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        DateTime fechaRegistro = dr.GetDateTime("fecha");
                        if ((fechaRegistro >= fecha1) && (fechaRegistro <= fecha2))
                        {
                            lista.Add(new Estatus(dr.GetDecimal("modificaciones"), dr.GetString("tipo"), dr.GetDateTime("fecha")));
                        }
                    }

                    dr.Close();
                }
            }
            return(lista);
        }
예제 #12
0
        private bool CargarDatosTicketPosicion()
        {
            string v_datos_posicion = null;

            ValidarConexion();

            if (Pro_Conexion.State != ConnectionState.Open)
            {
                Pro_Conexion.Open();
            }

            string       sentencia = @"SELECT * FROM area_servicio.ft_view_posicion_asignada (
                                                                                        :p_usuario, 
                                                                                        :p_agencia,
                                                                                        :p_cliente
                                                                                        );";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            pgComando.Parameters.Add("p_usuario", PgSqlType.VarChar).Value = Pro_UsuarioEmpleado;
            pgComando.Parameters.Add("p_agencia", PgSqlType.Int).Value     = Pro_Sucursal;
            pgComando.Parameters.Add("p_cliente", PgSqlType.Int).Value     = Pro_Cliente;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();

                if (pgDr.Read())
                {
                    v_datos_posicion = ConfigurationSettings.AppSettings["TEXTO_DESCRIPTIVO"] + " " +
                                       pgDr.GetString("posicion");
                }


                pgDr.Close();
                pgDr = null;
                pgComando.Dispose();
                sentencia = null;

                if (string.IsNullOrEmpty(v_datos_posicion))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception Exc)
            {
                DepuradorExcepciones v_depurador = new DepuradorExcepciones();
                v_depurador.CapturadorExcepciones(Exc,
                                                  this.Name,
                                                  "CargarDatosTicketPosicion()");
                v_depurador = null;
                MessageBox.Show(Exc.Message, "FLUCOL");
                return(false);
            }
        }
예제 #13
0
        private void CargarDatosEmpleadoParaEdicion(string pCodigoEmpleado)
        {
            ValidarConexion();

            string       sentencia = @"SELECT * FROM area_servicio.ft_view_datos_empleado_para_edicion(:pCodigoEmpleado);";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            pgComando.Parameters.Add("pCodigoEmpleado", PgSqlType.VarChar).Value = pCodigoEmpleado;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();

                int v_id_cargo   = 0;
                int v_id_agencia = 0;

                while (pgDr.Read())
                {
                    txtCodigoEmpleado.Text    = pgDr.GetString("codigo_empleado");
                    txtPrimerNombre.Text      = pgDr.GetString("primer_nombre");
                    txtSegundoNombre.Text     = pgDr.GetString("segundo_nombre");
                    txtPrimerApellido.Text    = pgDr.GetString("primer_apellido");
                    txtSegundoApellido.Text   = pgDr.GetString("segundo_apellido");
                    txtIdentidadEmpleado.Text = pgDr.GetString("identidad_empleado");
                    v_id_cargo   = pgDr.GetInt32("id_cargo");
                    v_id_agencia = pgDr.GetInt32("id_agencia");
                }

                foreach (dsConfiguraciones.dtCargosEmpleadosRow iterador in dsConfiguraciones1.dtCargosEmpleados)
                {
                    if (iterador.id_cargo == v_id_cargo)
                    {
                        gridCargos.EditValue = iterador.id_cargo;
                        break;
                    }
                }

                foreach (dsConfiguraciones.dtAgenciasServicioRow iterador in dsConfiguraciones1.dtAgenciasServicio)
                {
                    if (iterador.id_agencia_servicio == v_id_agencia)
                    {
                        gridAgencias.EditValue = iterador.id_agencia_servicio;
                        break;
                    }
                }

                pgDr.Close();
                sentencia = null;
                pgComando.Dispose();
            }
            catch (Exception Exc)
            {
                MessageBox.Show("ALGO SALIO EN EL MOMENTO DE REGISTRAR EL EMPLEADO. " + Exc.Message, "FLUCOL");
            }
        }
예제 #14
0
        private void LlamadoTickets()
        {
            ValidarConexion();

            PgSqlConnection vConexion = new PgSqlConnection(Pro_Conexion.ConnectionString);

            vConexion.Password = Pro_Conexion.Password;
            vConexion.Open();

            string       sentencia = @"SELECT * FROM area_servicio.ft_view_consulta_llamados_tickets (
                                                                                                :p_agencia_servicio,
                                                                                                :p_cliente_servicio
                                                                                                )";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, vConexion);

            pgComando.Parameters.Add("p_agencia_servicio", PgSqlType.Int).Value = Pro_Sucursal;
            pgComando.Parameters.Add("p_cliente_servicio", PgSqlType.Int).Value = Pro_ID_Cliente;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    v_ticket          = pgDr.GetString("ticket");
                    v_posicion        = pgDr.GetString("posicion");
                    v_tipo_ticket     = pgDr.GetInt32("tipo_ticket");
                    v_primera_letra   = pgDr.GetString("primera_letra");
                    v_segunda_letra   = pgDr.GetString("segunda_letra");
                    v_tercera_letra   = pgDr.GetString("tercera_letra");
                    v_cuarta_letra    = pgDr.GetString("cuarta_letra");
                    v_quinta_letra    = pgDr.GetString("quinta_letra");
                    v_sexta_letra     = pgDr.GetString("sexta_letra");
                    v_longitud_ticket = pgDr.GetInt32("longitud_ticket");

                    ReproducirAudioLlamadoTicket();
                }

                pgDr.Close();
                pgDr = null;
                pgComando.Dispose();
                vConexion.Close();
                vConexion.Dispose();
                sentencia = null;
            }
            catch (Exception Exc)
            {
                DepuradorExcepciones v_depurador = new DepuradorExcepciones();
                v_depurador.CapturadorExcepciones(Exc,
                                                  this.Name,
                                                  "LlamadoTickets()");
                v_depurador = null;
            }
        }
예제 #15
0
        private void GenerarTicket()
        {
            ValidarConexion();

            splashScreenManager1.ShowWaitForm();
            PgSqlTransaction pgTrans = Pro_Conexion.BeginTransaction();

            string       sentencia = @"SELECT * FROM configuracion.sp_proc_genera_correlativos_ticket (
                                                                                                :p_id_agencia_servicio,
                                                                                                :p_id_cliente_servicio,
                                                                                                :p_id_tipo_ticket_servicio,
                                                                                                :p_id_operacion_servicio,
                                                                                                :p_direccion_ip
                                                                                            );";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);

            pgComando.Parameters.Add("p_id_agencia_servicio", PgSqlType.Int).Value     = Pro_ID_AgenciaServicio;
            pgComando.Parameters.Add("p_id_cliente_servicio", PgSqlType.Int).Value     = Pro_ID_Cliente_Servicio;
            pgComando.Parameters.Add("p_id_tipo_ticket_servicio", PgSqlType.Int).Value = Pro_ID_Tipo_Ticket_Servicio;
            pgComando.Parameters.Add("p_id_operacion_servicio", PgSqlType.Int).Value   = Pro_ID_Operacion_Servicio;
            pgComando.Parameters.Add("p_direccion_ip", PgSqlType.VarChar).Value        = Pro_IP_Host;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();

                if (pgDr.Read())
                {
                    Pro_Ticket_Generado = pgDr.GetString("numero_ticket");
                }


                pgTrans.Commit();
                pgDr.Close();
                pgComando.Dispose();
                sentencia = null;

                splashScreenManager1.CloseWaitForm();
            }
            catch (Exception Exc)
            {
                splashScreenManager1.CloseWaitForm();
                pgTrans.Rollback();
                Pro_Ticket_Generado = null;
                MessageBox.Show(Exc.Message, "FLUCOL");
            }
        }
예제 #16
0
        private void ObtenerNombreSucursal()
        {
            if (Pro_Conexion.State != System.Data.ConnectionState.Open)
            {
                try
                {
                    Pro_Conexion.Open();
                }
                catch (Exception Exc)
                {
                    DepuradorExcepciones v_depurador = new DepuradorExcepciones();
                    v_depurador.CapturadorExcepciones(Exc,
                                                      this.Name,
                                                      "ObtenerNombreSucursal()");
                    v_depurador = null;
                }
            }

            try
            {
                string       sentencia = @"SELECT * FROM area_servicio.ft_view_nombre_agencia_servicio (
                                                                                                    :p_id_agencia_servicio,
                                                                                                    :p_id_cliente_servicio
                                                                                                 );";
                PgSqlCommand pgComando = new PgSqlCommand(sentencia, Pro_Conexion);
                pgComando.Parameters.Add("p_id_agencia_servicio", PgSqlType.Int).Value = Pro_ID_AgenciaServicio;
                pgComando.Parameters.Add("p_id_cliente_servicio", PgSqlType.Int).Value = Pro_ID_ClienteServicio;
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    Pro_NombreAgenciaServicio = pgDr.GetString("nombre_agencia");
                }

                pgDr.Close();
                pgComando.Dispose();
                sentencia = null;
            }
            catch (Exception Exc)
            {
                DepuradorExcepciones v_depurador = new DepuradorExcepciones();
                v_depurador.CapturadorExcepciones(Exc,
                                                  this.Name,
                                                  "ObtenerNombreSucursal()");
                v_depurador = null;
            }
        }
예제 #17
0
        public decimal getNumero()
        {
            decimal total = 0;

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = "select *from Numero";

                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        total = (dr.GetDecimal("numero"));
                    }
                }
            }
            return(total);
        }
예제 #18
0
        private int ObtenerEstadoTicket()
        {
            ValidarConexion();

            int          v_estado_ticket = 0;
            string       sentencia       = @"SELECT * FROM area_servicio.ft_view_estado_ticket (
                                                                                    :p_id_ticket_servicio,
                                                                                    :p_id_cliente_servicio,
                                                                                    :p_id_agencia_servicio
                                                                                    )";
            PgSqlCommand pgComando       = new PgSqlCommand(sentencia, Pro_Conexion);

            pgComando.Parameters.Add("p_id_ticket_servicio", PgSqlType.VarChar).Value = Pro_Ticket_Servicio;
            pgComando.Parameters.Add("p_id_cliente_servicio", PgSqlType.Int).Value    = Pro_ID_ClienteServicio;
            pgComando.Parameters.Add("p_id_agencia_servicio", PgSqlType.Int).Value    = Pro_ID_AgenciaServicio;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    v_estado_ticket = pgDr.GetInt32("estado");
                }

                pgDr.Close();
                sentencia = null;
                pgComando.Dispose();
                pgDr = null;

                return(v_estado_ticket);
            }
            catch (Exception Exc)
            {
                MessageBox.Show("ALGO SALIÓ MAL EN EL MOMENTO DE OBTENER ESTADO DEL TICKET. " + Exc.Message);

                DepuradorExcepciones v_depurador = new DepuradorExcepciones();
                v_depurador.CapturadorExcepciones(Exc,
                                                  this.Name,
                                                  "ObtenerEstadoTicket()");
                v_depurador = null;

                return(v_estado_ticket);
            }
        }
        private void CargarDatos()
        {
            PgSqlConnection v_conexion_temporal = new PgSqlConnection(Pro_Conexion.ConnectionString);

            v_conexion_temporal.Password = Pro_Conexion.Password;
            v_conexion_temporal.Open();

            string sentencia = @"SELECT * FROM area_servicio.ft_view_dashboard_empleados_con_mas_tickets_atendidos(:p_id_cliente_servicio,
                                                                                                                   :p_id_agencia_servicio,                                                                                                                  
                                                                                                                   :p_desde,
                                                                                                                   :p_hasta);";


            PgSqlCommand pgComando = new PgSqlCommand(sentencia, v_conexion_temporal);

            pgComando.Parameters.Add("p_id_cliente_servicio", PgSqlType.Int).Value = Pro_ID_Cliente_Servicio;
            pgComando.Parameters.Add("p_id_agencia_servicio", PgSqlType.Int).Value = Pro_ID_Agencia_Servicio;
            pgComando.Parameters.Add("p_desde", PgSqlType.Date).Value = Pro_Desde;
            pgComando.Parameters.Add("p_hasta", PgSqlType.Date).Value = Pro_Hasta;


            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    lblNombreEmpleado.Text         = pgDr.GetString("nombre_empleado");
                    lblNumeroTicketsAtendidos.Text = pgDr.GetString("numero_tickets_atendidos");
                    lblSucursalEmpleado.Text       = pgDr.GetString("agencia_servicio");
                }

                pgDr.Close();
                pgDr      = null;
                sentencia = null;
                pgComando.Dispose();
                v_conexion_temporal.Close();
                v_conexion_temporal.Dispose();
            }
            catch (Exception Exc)
            {
                MessageBox.Show("Algo salió mal en el momento de cargar Dashboard \"EMPLEADO CON MAS TICKETS ATENDIDOS\"." + Exc.Message);
            }
        }
예제 #20
0
        public decimal VerTotal()
        {
            decimal total = 0;

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = "select *from Caja WHERE id=1;";
                //SELECT *FROM productos WHERE codigo = '123456'

                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        total = (dr.GetDecimal("total"));
                    }
                }
            }
            return(total);
        }
예제 #21
0
        public List <Producto> ObtenerTodosLosProductos()
        {
            List <Producto> pro = new List <Producto>();

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = " SELECT * FROM productos";
                //SELECT *FROM productos WHERE codigo = '123456'
                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        pro.Add(new Producto(dr.GetInt32("id"), dr.GetString("codigo"), dr.GetString("descripcion"), dr.GetDecimal("precio")));
                    }
                }
            }

            return(pro);
        }
예제 #22
0
        public Producto ObtenerProductoPorCodigo_barras(string CodigoDeBarra)
        {
            Producto pro = new Producto();

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = " SELECT * FROM productos WHERE codigo = '" + CodigoDeBarra + "'";
                //SELECT *FROM productos WHERE codigo = '123456'


                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        pro = (new Producto(dr.GetInt32("id"), dr.GetString("codigo"), dr.GetString("descripcion"), dr.GetDecimal("precio")));
                    }
                }
            }
            return(pro);
        }
예제 #23
0
        public List <Socios> ObtenerSocios()
        {
            List <Socios> list = new List <Socios>();

            using (PgSqlCommand comand = conn.CreateCommand())
            {
                comand.CommandText = "SELECT * FROM socios";


                using (PgSqlDataReader dr = comand.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        list.Add(new Socios(dr.GetBoolean("administrador"), dr.GetString("nombre"), dr.GetString("contra"), dr.GetInt32("id")));
                    }
                    dr.Close();
                }
                return(list);
            }
        }
예제 #24
0
        public List <Inventario> Inventariado()
        {
            List <Inventario> list = new List <Inventario>();

            using (PgSqlCommand comand = conn.CreateCommand())
            {
                comand.CommandText = "SELECT p.codigo, p.descripcion, i.existencias FROM productos p INNER JOIN inventario i ON p.id= i.id ORDER BY existencias";


                using (PgSqlDataReader dr = comand.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        list.Add(new Inventario(dr.GetString("codigo"), dr.GetString("descripcion"), dr.GetInt32("existencias")));
                    }
                    dr.Close();
                }
                return(list);
            }
        }
예제 #25
0
        public List <Estatus> Estatus()
        {
            List <Estatus> lista = new List <Estatus>();

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = " select*from Modifica";

                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        lista.Add(new Estatus(dr.GetDecimal("modificaciones"), dr.GetString("tipo"), dr.GetDateTime("fecha")));
                    }

                    dr.Close();
                }
            }
            return(lista);
        }
예제 #26
0
        public IList <UsuarioDTO> CarregarUsuario()
        {
            PgSqlConnection conn = new PgSqlConnection("User Id=postgres;Password=root;host=localhost;database=NIVEL_ACESSO;");
            PgSqlCommand    cmd  = new PgSqlCommand();

            cmd.CommandText = "SELECT * FROM public.\"TRABALHADORES\"";
            cmd.Connection  = conn;
            conn.Open();

            int aff = cmd.ExecuteNonQuery();



            PgSqlDataReader ER;

            IList <UsuarioDTO> listaUsuarioDTO = new List <UsuarioDTO>();

            ER = cmd.ExecuteReader();

            if (ER.HasRows)
            {
                while (ER.Read())
                {
                    UsuarioDTO usuario = new UsuarioDTO();

                    usuario.Cpf           = Convert.ToString(ER["CPF"]);
                    usuario.Nome          = Convert.ToString(ER["NOME"]);
                    usuario.Email         = Convert.ToString(ER["EMAIL"]);
                    usuario.Login         = Convert.ToString(ER["LOGIN"]);
                    usuario.Status        = Convert.ToChar(ER["STATUS"]);
                    usuario.Senha         = Convert.ToString(ER["SENHA"]);
                    usuario.NivelDeAcesso = Convert.ToInt16(ER["NIVEL_DE_ACESSO"]);

                    listaUsuarioDTO.Add(usuario);
                }
            }

            conn.Close();

            return(listaUsuarioDTO);
        }
예제 #27
0
        public Producto ObtenerProductoNombre(string Nombre)
        {
            Producto pro = new Producto();

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = " select *FROM productos WHERE descripcion='" + Nombre + "'";
                ///select *FROM ventas WHERE fecha_venta= '2015/12/12'

                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        pro = new Producto(dr.GetInt32("id"), dr.GetString("codigo"), dr.GetString("descripcion"), dr.GetDecimal("precio"));
                    }

                    dr.Close();
                }
                return(pro);
            }
        }
예제 #28
0
        public int NumeroMaximoDeProductos()
        {
            int numeromaximo = 0;

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = "SELECT max(id)  from  productos; ";

                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        numeromaximo = dr.GetInt32("max");
                    }

                    dr.Close();
                }
            }

            return(numeromaximo + 1);
        }
예제 #29
0
        public bool NuevoIngreso()
        {
            bool ex = false;

            using (PgSqlCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = "select nombre from socios";

                using (PgSqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read() == true)
                    {
                        if (Convert.ToString(dr.GetString("nombre")) != "")
                        {
                            ex = true;
                        }
                    }
                }
            }
            return(ex);
        }
예제 #30
0
        private void CargarDatos()
        {
            PgSqlConnection v_conexion_temporal = new PgSqlConnection(Pro_Conexion.ConnectionString);

            v_conexion_temporal.Password = Pro_Conexion.Password;
            v_conexion_temporal.Open();

            string       sentencia = @"SELECT * FROM area_servicio.ft_view_dashboard_promedio_atencion(
                                                                                                 :p_id_cliente_servicio,
                                                                                                 :p_id_agencia_servicio,
                                                                                                 :p_desde,
                                                                                                 :p_hasta);";
            PgSqlCommand pgComando = new PgSqlCommand(sentencia, v_conexion_temporal);

            pgComando.Parameters.Add("p_id_cliente_servicio", PgSqlType.Int).Value = Pro_ID_ClienteServicio;
            pgComando.Parameters.Add("p_id_agencia_servicio", PgSqlType.Int).Value = Pro_ID_AgenciaServicio;
            pgComando.Parameters.Add("p_desde", PgSqlType.Date).Value = Pro_Desde;
            pgComando.Parameters.Add("p_hasta", PgSqlType.Date).Value = Pro_Hasta;

            try
            {
                PgSqlDataReader pgDr = pgComando.ExecuteReader();
                if (pgDr.Read())
                {
                    lblPromedioAtencion.Text = pgDr.GetString("promedio_atencion");
                }

                pgDr.Close();
                pgDr      = null;
                sentencia = null;
                pgComando.Dispose();
                v_conexion_temporal.Close();
                v_conexion_temporal.Dispose();
            }
            catch (Exception Exc)
            {
                MessageBox.Show("Algo salió mal en el momento de cargar Dashboard \"PROMEDIO DE ATENCION\"." + Exc.Message);
            }
        }
예제 #31
0
		static void Test(PgSqlConnection con, string sql, 
				CommandType cmdType, CommandBehavior behavior,
				string testDesc) 
		{ 
			PgSqlCommand cmd = null;
			PgSqlDataReader rdr = null;
			
			int c;
			int results = 0;

			Console.WriteLine("Test: " + testDesc);
			Console.WriteLine("[BEGIN SQL]");
			Console.WriteLine(sql);
			Console.WriteLine("[END SQL]");

			cmd = new PgSqlCommand(sql, con);
			cmd.CommandType = cmdType;
						
			Console.WriteLine("ExecuteReader...");
			rdr = cmd.ExecuteReader(behavior);

			if(rdr == null) {
		
				Console.WriteLine("IDataReader has a Null Reference.");
			}
			else {

				do {
					// get the DataTable that holds
					// the schema
					DataTable dt = rdr.GetSchemaTable();

					if(rdr.RecordsAffected != -1) {
						// Results for 
						// SQL INSERT, UPDATE, DELETE Commands 
						// have RecordsAffected >= 0
						Console.WriteLine("Result is from a SQL Command (INSERT,UPDATE,DELETE).  Records Affected: " + rdr.RecordsAffected);
					}
					else if (dt == null)
						Console.WriteLine("Result is from a SQL Command not (INSERT,UPDATE,DELETE).   Records Affected: " + rdr.RecordsAffected);
					else {
						// Results for
						// SQL not INSERT, UPDATE, nor DELETE
						// have RecordsAffected = -1
						Console.WriteLine("Result is from a SQL SELECT Query.  Records Affected: " + rdr.RecordsAffected);
			
						// Results for a SQL Command (CREATE TABLE, SET, etc)
						// will have a null reference returned from GetSchemaTable()
						// 
						// Results for a SQL SELECT Query
						// will have a DataTable returned from GetSchemaTable()

						results++;
						Console.WriteLine("Result Set " + results + "...");
                        			
						// number of columns in the table
						Console.WriteLine("   Total Columns: " +
							dt.Columns.Count);

						// display the schema
						foreach (DataRow schemaRow in dt.Rows) {
							foreach (DataColumn schemaCol in dt.Columns)
								Console.WriteLine(schemaCol.ColumnName + 
									" = " + 
									schemaRow[schemaCol]);
							Console.WriteLine();
						}

						int nRows = 0;
						string output, metadataValue, dataValue;
						// Read and display the rows
						Console.WriteLine("Gonna do a Read() now...");
						while(rdr.Read()) {
							Console.WriteLine("   Row " + nRows + ": ");
					
							for(c = 0; c < rdr.FieldCount; c++) {
								// column meta data 
								DataRow dr = dt.Rows[c];
								metadataValue = 
									"    Col " + 
									c + ": " + 
									dr["ColumnName"];
						
								// column data
								if(rdr.IsDBNull(c) == true)
									dataValue = " is NULL";
								else
									dataValue = 
										": " + 
										rdr.GetValue(c);
					
								// display column meta data and data
								output = metadataValue + dataValue;					
								Console.WriteLine(output);
							}
							nRows++;
						}
						Console.WriteLine("   Total Rows: " + 
							nRows);
					}	
				} while(rdr.NextResult());
				Console.WriteLine("Total Result sets: " + results);
			
				rdr.Close();
			}
					
		}
예제 #32
0
		public static void Main() {
			Console.WriteLine("** Start Test...");
			
			String connectionString = null;
			connectionString = 
				"host=localhost;" +
				"dbname=test;" +
				"user=postgres";
						
			PgSqlConnection con;
			Console.WriteLine("** Creating connection...");
			con = new PgSqlConnection(connectionString);
			Console.WriteLine("** opening connection...");
			con.Open();
		
			string tableName = "pg_type";

			string sql;
			sql = "SELECT * FROM PG_TABLES WHERE TABLENAME = :inTableName";
						
			Console.WriteLine("** Creating command...");
			PgSqlCommand cmd = new PgSqlCommand(sql, con);
			
			// add parameter for inTableName
			Console.WriteLine("** Create parameter...");
			PgSqlParameter parm = new PgSqlParameter("inTableName", DbType.String);
			
			Console.WriteLine("** set dbtype of parameter to string");
			parm.DbType = DbType.String;
			
			Console.WriteLine("** set direction of parameter to input");
			parm.Direction = ParameterDirection.Input;
			
			Console.WriteLine("** set value to the tableName string...");
			parm.Value = tableName;
			
			Console.WriteLine("** add parameter to parameters collection in the command...");
			cmd.Parameters.Add(parm);
			
			PgSqlDataReader rdr;
			Console.WriteLine("** ExecuteReader()...");
			
			rdr = cmd.ExecuteReader();
			
			Console.WriteLine("[][] And now we are going to our results [][]...");
			int c;
			int results = 0;
			do {
				results++;
				Console.WriteLine("Result Set " + results + "...");

				// get the DataTable that holds
				// the schema
				DataTable dt = rdr.GetSchemaTable();
                        			
				// number of columns in the table
				Console.WriteLine("   Total Columns: " +
					dt.Columns.Count);

				// display the schema
				foreach (DataRow schemaRow in dt.Rows) {
					foreach (DataColumn schemaCol in dt.Columns)
						Console.WriteLine(schemaCol.ColumnName + 
							" = " + 
							schemaRow[schemaCol]);
					Console.WriteLine();
				}

				string output, metadataValue, dataValue;
				int nRows = 0;

				// Read and display the rows
				while(rdr.Read()) {
					Console.WriteLine("   Row " + nRows + ": ");

					for(c = 0; c < rdr.FieldCount; c++) {
						// column meta data 
						DataRow dr = dt.Rows[c];
						metadataValue = 
							"    Col " + 
							c + ": " + 
							dr["ColumnName"];
						
						// column data
						if(rdr.IsDBNull(c) == true)
							dataValue = " is NULL";
						else
							dataValue = 
								": " + 
								rdr.GetValue(c);
					
						// display column meta data and data
						output = metadataValue + dataValue;					
						Console.WriteLine(output);
					}
					nRows++;
				}
				Console.WriteLine("   Total Rows: " + 
					nRows);
			} while(rdr.NextResult());
			Console.WriteLine("Total Result sets: " + results);

			con.Close();
		}