Ejemplo n.º 1
0
		protected override void EditTrustee()
		{
			if (lstVwTrustees.SelectedItems.Count == 0)
				return;

            ((frmMain)TopLevelControl).EnterWaitMode();
			ListViewItem item = null;
			GISADataset.TrusteeRow truRow = null;
			item = lstVwTrustees.SelectedItems[0];
			truRow = (GISADataset.TrusteeRow)item.Tag;
		
			GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
			try
			{
				if (TrusteeRule.Current.hasRegistos(((GISADataset.TrusteeRow)(lstVwTrustees.SelectedItems[0].Tag)).ID, ho.Connection))
					MessageBox.Show("Tenha em conta que alterações no nome de utilizador terá reflexos no registos no sistema.", "Utilizador", MessageBoxButtons.OK, MessageBoxIcon.Information);
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex);
				throw;
			}
			finally
			{
				ho.Dispose();
			}

			FormCreateTrustee form = new FormCreateTrustee();
			form.Text = "Editar utilizador";
			form.txtTrusteeName.Text = truRow.Name;
			switch (form.ShowDialog())
			{
				case DialogResult.OK:
		
					PersistencyHelper.EditTrusteePreConcArguments ctpca = new PersistencyHelper.EditTrusteePreConcArguments();
					ctpca.truRow = truRow;
					ctpca.username = form.txtTrusteeName.Text;

					Trace.WriteLine("A editar utilizador...");

					PersistencyHelper.save(EditTrusteeIfUsernameDoesntExist, ctpca);
					PersistencyHelper.cleanDeletedData();

					if (! ctpca.successful)
					{
						MessageBox.Show("Este nome já existe atribuído a um utilizador ou grupo, " + Environment.NewLine + "por favor escolha outro nome.", form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
						UpdateTrustees(null);
					}
					else
					{
						UpdateTrustees(truRow);
						UpdateContext();
					}
					UpdateToolBarButtons();
					break;
				case DialogResult.Cancel:
				    break;
			}
            ((frmMain)TopLevelControl).LeaveWaitMode();
		}
Ejemplo n.º 2
0
		protected override void EditTrustee()
		{
			if (lstVwTrustees.SelectedItems.Count == 0)
				return;

			GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
			try
			{
				if (TrusteeRule.Current.hasUsers(((GISADataset.TrusteeRow)(lstVwTrustees.SelectedItems[0].Tag)).ID, ho.Connection))
					MessageBox.Show("Tenha em conta que o Grupo de Utilizadores a editar já tem Utilizadores associados.", "Utilizador", MessageBoxButtons.OK, MessageBoxIcon.Warning);
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex);
				throw;
			}
			finally
			{
				ho.Dispose();
			}

			ListViewItem item = null;
			GISADataset.TrusteeRow truRow = null;
			item = lstVwTrustees.SelectedItems[0];
			truRow = (GISADataset.TrusteeRow)item.Tag;
            
			FormCreateTrustee form = new FormCreateTrustee();
			form.Text = "Editar grupo de utilizadores";
			form.txtTrusteeName.Text = truRow.Name;
			switch (form.ShowDialog())
			{
				case DialogResult.OK:

					PersistencyHelper.EditTrusteePreConcArguments etpca = new PersistencyHelper.EditTrusteePreConcArguments();
					etpca.truRow = truRow;
					etpca.username = form.txtTrusteeName.Text;

					Trace.WriteLine("A editar o grupo de utilizador...");

					PersistencyHelper.save(editTrusteeIfUsernameDoesntExist, etpca);
					PersistencyHelper.cleanDeletedData();

					if (! etpca.successful)
					{
						MessageBox.Show("Este nome já existe atribuído a um utilizador ou grupo, " + Environment.NewLine + "por favor escolha outro nome.", form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
						UpdateTrustees(null);
					}
					else
						UpdateTrustees(truRow);

					break;
				case DialogResult.Cancel:
				break;
			}
		}
Ejemplo n.º 3
0
		protected override void AddTrustee()
		{
			GISADataset.TrusteeRow truRow = null;
			GISADataset.TrusteeGroupRow grpRow = null;

			FormCreateTrustee form = new FormCreateTrustee();
			form.Text = "Novo grupo de utilizadores";
			switch (form.ShowDialog())
			{
				case DialogResult.OK:
					truRow = GisaDataSetHelper.GetInstance().Trustee.NewTrusteeRow();
					truRow.Name = form.txtTrusteeName.Text;
					truRow.Description = string.Empty;
					truRow.CatCode = "GRP";
					truRow.BuiltInTrustee = false;
					truRow.IsActive = true;
					truRow.Versao = new byte[]{};
					truRow.isDeleted = 0;
					grpRow = GisaDataSetHelper.GetInstance().TrusteeGroup.NewTrusteeGroupRow();
					grpRow.Versao = new byte[]{};
					grpRow.isDeleted = 0;
					grpRow.TrusteeRow = truRow;

					GisaDataSetHelper.GetInstance().Trustee.AddTrusteeRow(truRow);
					GisaDataSetHelper.GetInstance().TrusteeGroup.AddTrusteeGroupRow(grpRow);

					PersistencyHelper.CreateTrusteePreConcArguments ctpca = new PersistencyHelper.CreateTrusteePreConcArguments();
					ctpca.truRowID = truRow.ID;
					ctpca.grpRowID = grpRow.ID;

					Trace.WriteLine("A criar o grupo de utilizador...");

                    PersistencyHelper.SaveResult successfulSave = PersistencyHelper.save(addTrusteeIfUsernameDoesntExist, ctpca);
					PersistencyHelper.cleanDeletedData();

					if (! ctpca.successful)
					{
						MessageBox.Show("Este nome já existe atribuído a um utilizador ou grupo, " + Environment.NewLine + "por favor escolha outro nome.", form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
						UpdateTrustees(null);
					}
					else
						UpdateTrustees(truRow);

					break;
				case DialogResult.Cancel:
				break;
			}
		}
Ejemplo n.º 4
0
		protected override void AddTrustee()
		{
            GISADataset.TrusteeRow truRow = null;
			GISADataset.TrusteeUserRow usrRow = null;

			FormCreateTrustee form = new FormCreateTrustee();
			form.Text = "Novo utilizador";
			switch (form.ShowDialog())
			{
				case DialogResult.OK:
                    ((frmMain)TopLevelControl).EnterWaitMode();
					truRow = GisaDataSetHelper.GetInstance().Trustee.NewTrusteeRow();
					truRow.Name = form.txtTrusteeName.Text;
					truRow.Description = string.Empty;
					truRow.CatCode = "USR";
					truRow.BuiltInTrustee = false;
					truRow.IsActive = true;
					truRow.Versao = new byte[]{};
					truRow.isDeleted = 0;
					usrRow = GisaDataSetHelper.GetInstance().TrusteeUser.NewTrusteeUserRow();
					usrRow.Password = "";
					usrRow.FullName = "";
					usrRow.IsAuthority = false;
					usrRow["IDTrusteeUserDefaultAuthority"] = DBNull.Value;
					usrRow.Versao = new byte[]{};
					usrRow.isDeleted = 0;
					usrRow.TrusteeRow = truRow;

                    // selecionar o grupo "TODOS"
                    GISADataset.TrusteeGroupRow tgRow = (GISADataset.TrusteeGroupRow)(((GISADataset.TrusteeRow)(GisaDataSetHelper.GetInstance().Trustee.Select("Name='ACESSO_COMPLETO'")[0])).GetTrusteeGroupRows()[0]);

                    // incluir o novo utilizador no grupo "TODOS" por omissão
					GisaDataSetHelper.GetInstance().Trustee.AddTrusteeRow(truRow);
					GisaDataSetHelper.GetInstance().TrusteeUser.AddTrusteeUserRow(usrRow);
					GisaDataSetHelper.GetInstance().UserGroups.AddUserGroupsRow(usrRow, tgRow, new byte[]{}, 0);

					PersistencyHelper.CreateTrusteePreConcArguments ctpca = new PersistencyHelper.CreateTrusteePreConcArguments();
					ctpca.truRowID = truRow.ID;
					ctpca.usrRowID = usrRow.ID;

					Trace.WriteLine("A criar utilizador...");

                    PersistencyHelper.save(AddTrusteeIfUsernameDoesntExist, ctpca);
					PersistencyHelper.cleanDeletedData();

					if (! ctpca.successful)
					{
						MessageBox.Show("Este nome já existe atribuído a um utilizador ou grupo, " + Environment.NewLine + "por favor escolha outro nome.", form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
						UpdateTrustees(null);
					}
					else
					{
                        // actualizar interface
						UpdateTrustees(truRow);
					}

                    ((frmMain)TopLevelControl).LeaveWaitMode();
                    break;
				case DialogResult.Cancel:
				break;
			}
		}