示例#1
0
 private void btnModificar_Click(object sender, EventArgs e)
 {
     try
     {
         string          MyConnection2 = "server=localhost; database=hostal; Uid=root; pwd=root";
         string          Query         = "update hostal.huesped set PrimerNombre='" + this.txtPrimerNombre.Text + "',SegundoNombre='" + this.txtSegundoNombre.Text + "',PrimerApellido='" + this.txtPrimerApellido.Text + "',SegundoApellido='" + this.txtSegundoApellido.Text + "' where IdHuesped='" + this.txtIdHuesped.Text + "';";
         MySqlConnection MyConn2       = new MySqlConnection(MyConnection2);
         MySqlCommand    MyCommand2    = new MySqlCommand(Query, MyConn2);
         MySqlDataReader MyReader2;
         MyConn2.Open();
         MyReader2 = MyCommand2.ExecuteReader();
         MessageBox.Show("El cliente ha sido modificado.");
         dgvHuespedess.DataSource = null;
         dgvHuespedess.DataSource = obj.VistaTabla();
         Huesped limpiar = new Huesped();
         limpiar.BorrarCampos(this, groupBox1);
         //cbxTipoIdentificacion.Items.Clear();
         //cbxTipoIdentificacion.SelectedIndex = 0;
         while (MyReader2.Read())
         {
         }
         MyConn2.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#2
0
        private void btnGuardar_Click_1(object sender, EventArgs e)
        {
            Huesped pHuesped = new Huesped();

            pHuesped.PrimerNombre    = txtPrimerNombre.Text.Trim();
            pHuesped.SegundoNombre   = txtSegundoNombre.Text.Trim();
            pHuesped.PrimerApellido  = txtPrimerApellido.Text.Trim();
            pHuesped.SegundoApellido = txtSegundoApellido.Text.Trim();
            pHuesped.Compania        = Compania.Trim();
            pHuesped.NombreCompania  = txtNombreCompania.Text.Trim();
            pHuesped.TipoDocumento   = cbxTipoIdentificacion.Text.Trim();
            pHuesped.NumDocumento    = txtIdentificacion.Text.Trim();
            pHuesped.Sexo            = Sexo.Trim();
            pHuesped.Telefono        = txtTelefono.Text.Trim();
            pHuesped.Direccion       = txtDireccion.Text.Trim();
            pHuesped.Ciudad          = txtCiudad.Text.Trim();
            pHuesped.Provincia       = txtProvincia.Text.Trim();
            pHuesped.Pais            = txtPaisNatal.Text.Trim();
            pHuesped.Correo          = txtCorreo.Text.Trim();

            int resultado = HuespedD.Agregar(pHuesped);

            if (resultado > 0)
            {
                MessageBox.Show("Huesped guardado con exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dgvHuespedes.DataSource = null;
                dgvHuespedes.DataSource = obj.VistaTabla();
                Huesped limpiar = new Huesped();
                limpiar.BorrarCampos(this, groupBox1);
                //cbxTipoIdentificacion.Items.Clear();
                //cbxTipoIdentificacion.SelectedIndex = 0;
                rbtnSexoFemenino.Checked  = false;
                rbtnSexoMasculino.Checked = false;
                rbtnEsCompania.Checked    = false;
                rbtnNoCompania.Checked    = false;
            }
            else
            {
                MessageBox.Show("No se pudo guardar el huesped", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }