Beispiel #1
0
        private void modifyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Int32  id     = Convert.ToInt32(dg_rol.CurrentRow.Cells["Rol_Id"].Value);
            String nombre = Convert.ToString(dg_rol.CurrentRow.Cells["Rol_Nombre"].Value);

            Boolean available = Convert.ToBoolean(dg_rol.CurrentRow.Cells[2].Value);

            RoleDAO role = new RoleDAO();

            role.Id   = id;
            role.Name = nombre;

            this.Hide();
            FormAMRole form = new FormAMRole(role, false, available);

            form.ShowDialog();
            this.Show();
        }
Beispiel #2
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txt_add_name.Text.Trim()))
            {
                RoleDAO role = new RoleDAO();

                role.Name  = txt_add_name.Text.Trim();
                role.State = chk_available.Checked;

                RoleConnection.SaveRole(role);

                Int32 id = RoleConnection.GetRoleId(txt_add_name.Text.Trim());
                role.Id = id;

                if (MessageBox.Show("¿Desea agregarle funcionalidades ahora?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    this.Hide();
                    FormAMRole form = new FormAMRole(role, true, false);
                    form.ShowDialog();
                    this.Show();
                }
                else
                {
                    MessageBox.Show("El rol se ha guardado correctamente.");
                    txt_add_name.Text     = "";
                    chk_available.Checked = false;
                    groupBoxAdd.Enabled   = false;
                }
            }
            else
            {
                MessageBox.Show("Debe indicar el nombre del nuevo rol.");
            }

            RoleConnection.LoadDGV(dg_rol);
        }