private void GenerarReservaButton_Click(object sender, EventArgs e)
 {
     FormGenerarReserva r = new FormGenerarReserva();
     this.Hide();
     r.ShowDialog();
     this.Close();
 }
        private void GenerarReservaButton_Click(object sender, EventArgs e)
        {
            FormGenerarReserva r = new FormGenerarReserva();

            this.Hide();
            r.ShowDialog();
            this.Close();
        }
Exemple #3
0
        private void modificarButton_Click(object sender, EventArgs e)
        {
            conexion.Open();

            string id = "SELECT ID_Cliente " +
                        "FROM AEFI.TL_Reserva " +
                        "WHERE ID_Reserva = " + BaseDeDatos.agregarApostrofos(txbCodigoReserva.Text);
            SqlCommand    comando = new SqlCommand(id, conexion);
            SqlDataReader reader  = comando.ExecuteReader();

            reader.Read();
            idCliente = Convert.ToInt32(reader[0]);

            conexion.Close();
            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                FormGenerarReserva alta = new FormGenerarReserva(idCliente, Convert.ToInt32(txbCodigoReserva.Text), row.Cells);
                this.Hide();
                alta.ShowDialog();
                this.Close();
            }
        }
        private void modificarButton_Click(object sender, EventArgs e)
        {
            conexion.Open();

            string id = "SELECT ID_Cliente " +
                        "FROM AEFI.TL_Reserva " +
                        "WHERE ID_Reserva = " + BaseDeDatos.agregarApostrofos(txbCodigoReserva.Text);
            SqlCommand comando = new SqlCommand(id, conexion);
            SqlDataReader reader = comando.ExecuteReader();
            reader.Read();
            idCliente = Convert.ToInt32(reader[0]);

            conexion.Close();
            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                FormGenerarReserva alta = new FormGenerarReserva(idCliente,Convert.ToInt32(txbCodigoReserva.Text) ,row.Cells);
                this.Hide();
                alta.ShowDialog();
                this.Close();
            }
        }
Exemple #5
0
        private void CrearButton_Click(object sender, EventArgs e)
        {
            if (verificarTextBoxNoVacios())
            {

                try
                {
                    conexion.Open();

                    if (x == 0)
                    {

                       SqlCommand comando = new SqlCommand("AEFI.insertar_cliente", conexion);
                       comando.CommandType = CommandType.StoredProcedure;
                        aniadirParametros(comando);
                    }
                    else if (x == 1)
                    {
                        SqlCommand comando = new SqlCommand("AEFI.actualizar_cliente", conexion);
                        comando.CommandType = CommandType.StoredProcedure;
                        comando.Parameters.Add(new SqlParameter("@ID_Cliente", id_cliente));
                        aniadirParametros(comando);
                    }
                    else if (x == 2)
                    {
                     SqlCommand comando = new SqlCommand("AEFI.insertar_cliente", conexion);
                        comando.CommandType = CommandType.StoredProcedure;
                        aniadirParametros(comando);

                        string consultaID = "SELECT ID_Cliente "
                                          + "FROM AEFI.TL_Cliente "
                                          + "WHERE Mail = " + BaseDeDatos.agregarApostrofos(txbMail.Text);//ya que no hay 2 mails iguales

                        SqlCommand comandoId = new SqlCommand(consultaID, conexion);
                        SqlDataReader readerId = comandoId.ExecuteReader();
                        readerId.Read();
                        int id = Convert.ToInt32(readerId[0]);
                        readerId.Close();

                        string cantidadDeClientes = "SELECT COUNT(ID_Cliente) " +
                                                    "FROM AEFI.TL_Cliente ";

                        //perdon Esme la costumbre gana, tengo que crear otro commando :P
                        SqlCommand comandoCant = new SqlCommand(cantidadDeClientes, conexion);
                        SqlDataReader readerCant = comandoCant.ExecuteReader();
                        readerCant.Read();
                        int cantDeClientesDespues = Convert.ToInt32(readerCant[0]);

                        if (cantDeClientesAntes != cantDeClientesDespues)
                        {//significa que si se ingreso un cliente
                            FormGenerarReserva r = new FormGenerarReserva(id);
                            this.Hide();
                            r.ShowDialog();
                            this.Close();
                        }
                        else
                        {
                            FormMenu m = new FormMenu();
                            this.Hide();
                            m.ShowDialog();
                            this.Close();
                        }
                    }

                }
                catch (Excepciones exc)
                {
                    MessageBox.Show(exc.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    conexion.Close();

                    FormMenu m = new FormMenu();
                    this.Hide();
                    m.ShowDialog();
                    this.Close();

                }
            }
            else
            {
                MessageBox.Show("Debe completar todos los campos", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }