Ejemplo n.º 1
0
 private void btChange_Click(object sender, EventArgs e)
 {
     if (_title == "Utilizadores - Alterar")
     {
         int id;
         int.TryParse(gvResultUsers.CurrentRow.Cells["UserID"].Value.ToString(), out id);
         FrmUser_InsertUpdate frmUser_Update = new FrmUser_InsertUpdate(false, id);
         frmUser_Update.ShowDialog();
         FillGrid();
     }
     else if (_title == "Utilizadores - Bloquear / Desbloquear")
     {
         DialogResult res = MessageBox.Show("Tem a certeza que pretende bloquear?", "Atenção!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (res == DialogResult.Yes)
         {
             int id;
             int.TryParse(gvResultUsers.CurrentRow.Cells["UserID"].Value.ToString(), out id);
             user.ID        = id;
             user.IsBlocked = true;
             _service.UpdateBlockedStatus(user);
             MessageBox.Show("Bloqueado com sucesso", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             FillGrid();
         }
     }
     else
     {
         DialogResult res = MessageBox.Show("Tem a certeza que pretende eliminar?", "Atenção!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (res == DialogResult.Yes)
         {
             int id;
             int.TryParse(gvResultUsers.CurrentRow.Cells["UserID"].Value.ToString(), out id);
             _service.Remove(id);
         }
         else
         {
             FillGrid();
         }
     }
     FillGrid();
 }
Ejemplo n.º 2
0
 private void inserirUserToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Application.OpenForms.OfType <FrmUser_InsertUpdate>().Count() == 0)
     {
         frmUser_InsertUpdate = new FrmUser_InsertUpdate(true);
     }
     //FrmUser_InsertUpdate.MdiParent = this;
     frmUser_InsertUpdate.BringToFront();
     frmUser_InsertUpdate.ShowDialog();
     if (Application.OpenForms.OfType <FrmUser>().Count() == 0)
     {
         frmUser = new FrmUser("Utilizadores - Alterar");
     }
     else
     {
         frmUser.Close();
         frmUser = new FrmUser("Utilizadores - Alterar");
     }
     frmUser.MdiParent   = this;
     frmUser.WindowState = FormWindowState.Maximized;
     frmUser.Show();
     frmUser.BringToFront();
 }