Ejemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                this.ValidateForm();
                int idUsuario = this.UsuarioService.Save(this.GetUsuario());

                MessageBox.Show("El usuario fue guardado correctamente", "Success", MessageBoxButtons.OK);

                var form = new UsuarioForm(idUsuario);
                form.Location      = this.Location;
                form.StartPosition = FormStartPosition.Manual;
                form.FormClosing  += delegate { this.Show(); };
                form.Show();
                this.Close();
            }
            catch (FormException formException)
            {
                MessageBox.Show(formException.Message, "Error", MessageBoxButtons.OK);
            }
            catch
            {
                MessageBox.Show("Ocurrio un error", "Error", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 2
0
 private void dgvUsuario_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 0)
     {
         DataGridViewRow  row  = dgvUsuario.Rows[e.RowIndex];
         DataGridViewCell cell = row.Cells["Id"];
         var form = new UsuarioForm((int)cell.Value);
         this.DisplayForm(form);
     }
 }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBoxFuncionalidad.Text.Length == 0)
            {
                MessageBox.Show("Primero debes elegir una opción.");
            }
            else if (comboBoxFuncionalidad.Text == "Editar Usuario Existente" && textBoxUsuario.Text.Length == 0)
            {
                MessageBox.Show("Primero debes ingresar un usuario valido.");
            }
            else if (comboBoxFuncionalidad.Text == "Crear Usuario Nuevo")
            {
                this.Hide();
                UsuarioForm abm_usuario = new UsuarioForm();
                abm_usuario.nombre_usuario = "";
                abm_usuario.StartPosition  = FormStartPosition.CenterScreen;
                abm_usuario.ShowDialog();
            }
            else
            {
                connection = new System.Data.SqlClient.SqlConnection();
                try
                {
                    connection.ConnectionString = Variables.connectionStr;
                    connection.Open();
                    string query = "select * from GITAR_HEROES.Usuario where username = '******'";
                    command            = new SqlCommand(query);
                    command.Connection = connection;
                    adapter            = new SqlDataAdapter(command);
                    dataTable          = new DataTable();
                    adapter.Fill(dataTable);

                    // validar usuario valido
                    if (dataTable.Rows.Count > 0 && textBoxUsuario.Text != "guest" && textBoxUsuario.Text != "Guest")
                    {
                        this.Hide();
                        UsuarioForm abm_usuario = new UsuarioForm();
                        abm_usuario.nombre_usuario = textBoxUsuario.Text;
                        abm_usuario.StartPosition  = FormStartPosition.CenterScreen;
                        abm_usuario.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error: No existe ningún usuario con dicho nombre.");
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Error: " + exc);
                }
            }
        }
Ejemplo n.º 4
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            var form = new UsuarioForm();

            this.DisplayForm(form);
        }