Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - m@o_614

#291
saludos tengo este codigo que me esta dando un error en la parte de buscar, que me tiene que buscar un numero de cuenta y si lo encuentra mostrarme todos los demas datos de la entidad, me dice que no se puede convertir de datePicker a string

Código (csharp) [Seleccionar]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Npgsql;

namespace Agencia_de_Viajes
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();
        }

        private void irMenu_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            Form1 menu = new Form1();
            menu.Visible = true;
        }

        private void cmdAgregar_Click(object sender, EventArgs e)
        {
            if (txtNumeroCuenta.Text == "" || txtDescripcion.Text == "" || txtIdCliente.Text == "")
            {
                MessageBox.Show("DEBES INTRODUCIR VALORES...");
            }         
            else
            {
                int NUMERO = Convert.ToInt16(txtNumeroCuenta.Text);
                string DESCRIPCION = txtDescripcion.Text;
                int ID = Convert.ToInt16(txtIdCliente.Text);
                string FECHA = dateTimePicker1.Value.ToString("yyyy-MM-dd");

                try
                {
                    IDbConnection dbcon = new NpgsqlConnection("Server = localhost;" + "Database = Facturas;" + "User ID = marcela;");
                    dbcon.Open();
                    IDbCommand dbcmd = dbcon.CreateCommand();
                    dbcmd.CommandText = "insert into Cuentas_extras values(" + NUMERO + ",'" + DESCRIPCION + "'," + ID + ",'" + FECHA + "');";
                    IDataReader reader = dbcmd.ExecuteReader();
                    dbcon.Close();
                    txtNumeroCuenta.Text = "";
                    txtDescripcion.Text = "";
                    txtIdCliente.Text = "";
                    MessageBox.Show("Registro Guardado correctamente");
                }
                catch (Exception msg)
                {
                    MessageBox.Show("error.....\n\n" + msg.ToString());
                }
            }
        }

        private void cmdMostrar_Click(object sender, EventArgs e)
        {
            try
            {
                NpgsqlConnection conexion = new NpgsqlConnection("Server = localhost; " + "Database = Facturas;" + "User ID = marcela;");

                NpgsqlDataAdapter adaptador = new NpgsqlDataAdapter("select * from Cuentas_extras", conexion);
                DataTable tablamemoria = new DataTable();
                adaptador.Fill(tablamemoria);
                dtaCuentasExtras.DataSource = tablamemoria.DefaultView;
            }

            catch (Exception msg)
            {
                MessageBox.Show("Error......\n\n" + msg.ToString());
            }
        }

        int n;
        private void cmdBuscar_Click(object sender, EventArgs e)
        {
            if (txtBuscado.Text == "")
            {
                MessageBox.Show("DEBES INTRODUCIR EL NUMERO DE CUENTA A BUSCAR...");
                txtBuscado.Focus();
            }
            else
            {
                try
                {
                    int band = 0;
                    IDbConnection dbcon = new NpgsqlConnection("Server = localhost;" + "Database = Facturas;" + "User ID = marcela;");
                    dbcon.Open();
                    IDbCommand dbcmd = dbcon.CreateCommand();
                    n = Convert.ToInt32(txtBuscado.Text);
                    dbcmd.CommandText = "select * from cuentas_extras where numero_cuenta =" + n + "";
                    IDataReader reader = dbcmd.ExecuteReader();
                    if (reader.Read())
                    {
                        txtDescripcion.Text = reader.GetString(reader.GetOrdinal("descripcion"));
                        txtIdCliente.Text = Convert.ToString(reader.GetInt32(reader.GetOrdinal("id_cliente")));
                        txtNumeroCuenta.Text = Convert.ToString(reader.GetInt32(reader.GetOrdinal("numero_cuenta")));
                        dateTimePicker1.Text = reader.GetString(reader.GetOrdinal("fecha"));
                        band = 1;
                        txtBuscado.Text = "";
                    }
                    dbcon.Close();
                    if (band == 0)
                    {
                        txtBuscado.Text = "";
                        txtDescripcion.Text = "";
                        txtIdCliente.Text = "";
                        txtNumeroCuenta.Text = "";
                        MessageBox.Show("Numero de cuenta no encontrado");
                    }
                }
                catch (Exception msg)
                {
                    MessageBox.Show(msg.ToString());
                }
            }
        }
    }
}


gracias
#292
Programación C/C++ / aprender c#
14 Mayo 2013, 01:17 AM
Saludos

Alguien sabe de algun curso on-line para principiantes de c# o algun libro que sea bueno para aprender este lenguaje

gracias de antemano
#293
Foro Libre / Pastebin
7 Mayo 2013, 05:06 AM
Alguien sabe porque bloquearon pastebin???? No se si esto es en todos los paises o si es algun asunto de las empresas de internet
#294
Programación C/C++ / invalid input syntax
4 Mayo 2013, 18:25 PM
saludos tengo el siguiente codigo en c# pero me sale un error en la linea numero 45 que dice: invalid input syntax for integer...

Código (csharp) [Seleccionar]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Npgsql;

namespace Agencia_de_Viajes
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();
        }

        private void irMenu_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            Form1 menu = new Form1();
            menu.Visible = true;
        }

        private void cmdAgregar_Click(object sender, EventArgs e)
        {
            if (txtNumero.Text == "" || txtDescripcion.Text == "" || txtFecha.Text == "" || txtIdCliente.Text == "")
            {
                MessageBox.Show("DEBES INTRODUCIR VALORES...");
            }
            else
            {
                try
                {
                    int NUMERO = Convert.ToInt16(txtNumero.Text);
                    string DESCRIPCION = txtDescripcion.Text;
                    DateTime today = DateTime.Today;
                    string FECHA = today.ToString("yyyy/MM/dd");
                    int ID = Convert.ToInt16(txtIdCliente.Text);
                    IDbConnection dbcon = new NpgsqlConnection("Server = localhost;" + "Database = Facturas;" + "User ID = marcela;");
                    dbcon.Open();
                    IDbCommand dbcmd = dbcon.CreateCommand();
                    dbcmd.CommandText = "insert into Cuentas_extras values(" + NUMERO + ",'" + DESCRIPCION + "','" + FECHA + "'," + ID + ")";
                    IDataReader reader = dbcmd.ExecuteReader();
                    dbcon.Close();
                    txtNumero.Text = "";
                    txtDescripcion.Text = "";
                    txtFecha.Text = "";
                    txtIdCliente.Text = "";
                    MessageBox.Show("Registro Guardado correctamente");
                }
                catch (Exception msg)
                {
                    MessageBox.Show("error.....\n\n" + msg.ToString());
                }
            }
        }

        private void cmdMostrar_Click(object sender, EventArgs e)
        {
            try
            {
                NpgsqlConnection conexion = new NpgsqlConnection("Server = localhost; " + "Database = Facturas;" + "User ID = marcela;");

                NpgsqlDataAdapter adaptador = new NpgsqlDataAdapter("select * from Cuentas_extras", conexion);
                DataTable tablamemoria = new DataTable();
                adaptador.Fill(tablamemoria);
                dtaCuentasExtras.DataSource = tablamemoria.DefaultView;
            }

            catch (Exception msg)
            {
                MessageBox.Show("Error......\n\n" + msg.ToString());
            }
        }
    }
}
el problema es cuando le agrego una fecha cualquiera (2013/04/04) es ahi donde me marca el error

de antemano gracias
#295
Bases de Datos / eliminar llave primaria
2 Mayo 2013, 18:10 PM
saludos

tengo una entidad en postgres que contiene una llave primaria, al principio intente eliminar toda la entidad con:

drop table nombre_tabla;

pero me aparecio un error que decia que primero tenia que eliminar la llave primaria, pero cuando le pongo

alter table nombre_tabla drop primary key; o cuando le pongo esta otra

alter table nombre_tabla drop primary key(nombre de la columna que tiene el primary key);

pero me sale un sintax error y no se por que, alguien sabe de algun comando para solucionar esto??? como le borro la llave primaria a mi tabla???

gracias
#296
saludos

Tengo una duda conceptual de el manejo de llaves en una base de datos, una entidad puede tener dos llaves foraneas pero ninguna primaria??? es valido esto?

de antemano gracias
#297
Software / Visual Studio
22 Abril 2013, 03:48 AM
Saludos

Tengo un problema no puedo abrir un proyecto en visual studio y no entiendo por qué, me aparece un mensaje que dice que no se pudo cargar el archivo del proyecto blablabla y otro que dice no se puede encontrar parte de la ruta de acceso

al que me pueda ayudar de antemano gracias
#298
Programación C/C++ / Re: StackOverFlow
21 Abril 2013, 04:05 AM
Saludos

ahora ya tengo un poco más claro de por qué me aparecía el error de StackOverFlow, era la manera en la que estaba instanciando las cosas


Esta es el código de la ventana menú que va a estar enlazada con varios botones que a su vez van a tener un boton para regresar al menú

Algo así como un ir y venir

Código (csharp) [Seleccionar]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Agencia_de_Viajes
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            Form1 menu = new Form1();
        }

        Form2 clientes = new Form2(this);//Aquí me marca error
        Form3 aerolinea = new Form3();
        Form4 hospedaje = new Form4();
        Form5 cuentasExtras = new Form5();
        Form6 detalleFolio = new Form6();
        Form7 detalleVentaAvion = new Form7();
        Form8 detalleVentaHotel = new Form8();
        Form9 presupuesto = new Form9();
        Form10 reservacionesAereas = new Form10();
        Form11 reservacionesHotel = new Form11();
        Form12 ventaBoletoAvion = new Form12();
        Form13 ventaHotel = new Form13();

        private void cmdClientes_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            clientes.Visible = true;
        }

        private void cmdAerolinea_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            aerolinea.Visible = true;
        }

        private void cmdCuentas_Extras_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            cuentasExtras.Visible = true;
        }

        private void cmdDetalle_Folio_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            detalleFolio.Visible = true;
        }

        private void cmdDetalle_Venta_Avion_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            detalleVentaAvion.Visible = true;
        }

        private void cmdDetalle_Venta_Hotel_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            detalleVentaHotel.Visible = true;
        }

        private void cmdPresupuesto_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            presupuesto.Visible = true;
        }

        private void cmdReservaciones_Aereas_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            reservacionesAereas.Visible = true;
        }

        private void cmdReservaciones_Hotel_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            reservacionesHotel.Visible = true;
        }

        private void cmdVenta_Boleto_Avion_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            ventaBoletoAvion.Visible = true;
        }

        private void cmdVenta_Hotel_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            ventaHotel.Visible = true;
        }

        private void alojamiento_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            hospedaje.Visible = true;
        }

        private void cmdSalir_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}


y aqui esta la otra ventana

Código (csharp) [Seleccionar]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Agencia_de_Viajes
{
    public partial class Form2 : Form
    {
        Form1 menu;
        public Form2(Form1 menu)
        {
            this.menu = menu;
        }

        private void irMenu_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            menu.Visible = true;
        }
    }
}
pero en la primer ventana me marca un error en el this que dice que no esta disponible en el contexto actual
#299
Programación C/C++ / StackOverFlow
20 Abril 2013, 03:11 AM
Saludos

Estoy haciendo una base de datos que tiene un menu y unas 12 entidades, y les estoy haciendo su interfaz gráfica en c#, estas ventanas tienen que estar enlazadas y la primera vez que lo compile me salió bien los botones del menú me llevaban a la ventana correspodiente y tal. Pero ahora no me compila me aparece un error que dice

No se controló StackOverFlowException

No se puede evaluar la expresión porque el subproceso actual está en un estado de desbordamiento de pila

y me aparece este código también pero no tengo idea de qué significa

Código (csharp) [Seleccionar]
//
            // Form3
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(388, 347);
            this.Controls.Add(this.cmdIr_Menu);
            this.Controls.Add(this.dataGridView1);
            this.Controls.Add(this.cmdMostrar);
            this.Controls.Add(this.cmdAgregar);
            this.Controls.Add(this.txtServicios);
            this.Controls.Add(this.txtCategoria);
            this.Controls.Add(this.txtTipo);
            this.Controls.Add(this.txtTel);
            this.Controls.Add(this.txtUbicacion);
            this.Controls.Add(this.txtIdHotel);
            this.Controls.Add(this.txtNombre);
            this.Controls.Add(this.servicios);
            this.Controls.Add(this.categoria);
            this.Controls.Add(this.tipo);
            this.Controls.Add(this.txtTelefono);
            this.Controls.Add(this.ubicacion);
            this.Controls.Add(this.idHotel);
            this.Controls.Add(this.nombre);
            this.Controls.Add(this.alojamiento);
            this.Name = "Form3";
            this.Text = "Form3";
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
            this.ResumeLayout(false);//Aqui esta el error
            this.PerformLayout();

        }


el error supuestamente esta en las ultimas lineas, la verdad estoy medio desesperada porque segun yo no habia nada mal

si alguien me pudiera ayudar le agradeceria mucho
#300
Bases de Datos / Re: alter column
19 Abril 2013, 20:35 PM
Saludos

ya lo pude resolver lo único que hice fue ponerle drop table clientes

para ya despues crearla con los tipos de datos correctos

gracias