예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text.Trim() == txtPassword2.Text.Trim())
            {
                try
                {
                    if (txtIDUser.Text.Trim() != "" &&
                        txtNameUser.Text.Trim() != "" &&
                        txtNickName.Text.Trim() != "" &&
                        txtPassword.Text.Trim() != "" &&
                        txtPassword2.Text.Trim() != "")
                    {
                        newUser.ID       = txtIDUser.Text.Trim();
                        newUser.Name     = txtNameUser.Text.Trim();
                        newUser.NickName = txtNickName.Text.Trim();
                        newUser.Password = txtPassword.Text.Trim();
                        newUser.Active   = ckbActive.Checked;

                        DaoUser.insertUser(newUser);
                        GetAllUsers();
                        MessageBox.Show("Cuenta guardada:\n" + newUser.Name,
                                        "Información",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Campos obligatorios:\n* Identificación\n* Nombre\n* NickName\n* PassWord",
                                        "Validación",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:\n" + ex.Message,
                                    "Error al insertar",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Las Contraseñas ingresadas no coinciden",
                                "Validación",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
        }