Exemplo n.º 1
0
        private void btnAutoEliminacaoManager_Click(object sender, System.EventArgs e)
        {
            FormAutoEliminacaoEditor formAutoEditor = new FormAutoEliminacaoEditor();
            IDbConnection            conn           = GisaDataSetHelper.GetConnection();

            try
            {
                conn.Open();
                RelatorioRule.Current.LoadAutosEliminacao(GisaDataSetHelper.GetInstance(), conn);
            }
            finally
            {
                conn.Close();
            }

            formAutoEditor.LoadData(GisaDataSetHelper.GetInstance().AutoEliminacao.Select(string.Empty, "Designacao"), "Designacao");
            formAutoEditor.ShowDialog();

            PersistencyHelper.save();
            PersistencyHelper.cleanDeletedData();

            long selectedAutoEliminacaoID = 0;

            if (cbAutoEliminacao.SelectedValue == null)
            {
                selectedAutoEliminacaoID = long.MinValue;
            }
            else
            {
                selectedAutoEliminacaoID = (long)cbAutoEliminacao.SelectedValue;
            }

            rebindToData();
            cbAutoEliminacao.SelectedValue = selectedAutoEliminacaoID;
        }
Exemplo n.º 2
0
		public override void ModelToView()
		{
			IsPopulated = false;
			byte[] Versao = null;
			string QueryFilter = "IDFRDBase=" + CurrentFRDBase.ID.ToString();
			if (GisaDataSetHelper.GetInstance().SFRDConteudoEEstrutura. Select(QueryFilter).Length != 0)
			{

				CurrentSFRDConteudoEEstrutura = (GISADataset.SFRDConteudoEEstruturaRow)(GisaDataSetHelper.GetInstance(). SFRDConteudoEEstrutura.Select(QueryFilter)[0]);
			}
			else
			{
				CurrentSFRDConteudoEEstrutura = GisaDataSetHelper.GetInstance().SFRDConteudoEEstrutura. AddSFRDConteudoEEstruturaRow(CurrentFRDBase, "", "", Versao, 0);
			}

			if (! (CurrentSFRDConteudoEEstrutura.IsIncorporacaoNull()))
			{
				txtIncorporacoes.Text = CurrentSFRDConteudoEEstrutura.Incorporacao;
			}
			else
			{
				txtIncorporacoes.Text = "";
			}
			IsPopulated = true;
		}
Exemplo n.º 3
0
        public static void ValidateMovimentoDelete(PersistencyHelper.PreConcArguments args)
        {
            var vmdiPsa = args as PersistencyHelper.ValidateMovimentoDeleteItemPreConcArguments;
            var dmRow   = GisaDataSetHelper.GetInstance().DocumentosMovimentados.Cast <GISADataset.DocumentosMovimentadosRow>()
                          .SingleOrDefault(r => r.RowState == DataRowState.Deleted && (long)r["IDNivel", DataRowVersion.Original] == vmdiPsa.IDNivel && (long)r["IDMovimento", DataRowVersion.Original] == vmdiPsa.IDMovimento);

            // este caso acontece quando a linha está detached (o documento foi adicionado, e antes de ser gravado, foi removido da requisição/devolução)
            if (dmRow == null)
            {
                return;
            }

            // não é permitido eliminar a associação de documentos a devoluções com requisições posteriores mas sem devolução
            // não é permitido eliminar a associação de documentos a requisições com devolução posterior
            vmdiPsa.continueSave = !DBAbstractDataLayer.DataAccessRules.MovimentoRule.Current.temMovimentosPosteriores(vmdiPsa.IDNivel, vmdiPsa.IDMovimento, vmdiPsa.CatCode, args.tran);

            if (vmdiPsa.continueSave)
            {
                return;
            }

            System.Data.DataSet tempgisaBackup2 = vmdiPsa.gisaBackup;
            PersistencyHelper.BackupRow(ref tempgisaBackup2, dmRow);
            vmdiPsa.gisaBackup = tempgisaBackup2;
            dmRow.RejectChanges();
        }
Exemplo n.º 4
0
        private void btn_Add_Averbamento_Click(object sender, EventArgs e)
        {
            FormLeitura_Designacao formLeitura = new FormLeitura_Designacao();

            formLeitura.Title      = "Averbamento de requerente/proprietário";
            formLeitura.LabelTitle = "Nome do requerente/proprietário";
            GISADataset.LicencaObraRequerentesRow requerente = null;

            switch (formLeitura.ShowDialog())
            {
            case DialogResult.OK:
                if (!existe_LicencaObraRequerenteAvrb(formLeitura.Designacao))
                {
                    requerente = GisaDataSetHelper.GetInstance().LicencaObraRequerentes.NewLicencaObraRequerentesRow();
                    requerente.LicencaObraRow = CurrentLicencaObra;
                    requerente.Nome           = formLeitura.Designacao;
                    // TIPO = 'AVRB'
                    requerente.Tipo      = "AVRB";
                    requerente.isDeleted = 0;
                    // Dados:
                    GisaDataSetHelper.GetInstance().LicencaObraRequerentes.AddLicencaObraRequerentesRow(requerente);
                    // GUI:
                    ListViewItem item = this.lstVwAverbamentos.Items.Add(requerente.Nome);
                    item.Tag = requerente;
                }

                break;
            }
        }
Exemplo n.º 5
0
        // Adicionar uma localizacao actual (registo de autoridade geográfico):
        private void btnAdd_Localizacao_Actual_Click(object sender, EventArgs e)
        {
            GISADataset.ControloAutRow caRow = null;
            GISADataset.LicencaObraLocalizacaoObraActualRow locActualRow  = null;
            GISADataset.ControloAutDicionarioRow            dicionarioRow = null;

            FormLeituraLocalizacaoNumPolicia formLeitura = new FormLeituraLocalizacaoNumPolicia();

            formLeitura.ModoTextoLivre = false;

            switch (formLeitura.ShowDialog())
            {
            case DialogResult.OK:
                dicionarioRow = formLeitura.ControloAutDicionarioRow;
                caRow         = dicionarioRow.ControloAutRow;
                if (!existe_LicencaObraLocalizacaoObraActual(caRow, formLeitura.NumeroPolicia))
                {
                    locActualRow = GisaDataSetHelper.GetInstance().LicencaObraLocalizacaoObraActual.NewLicencaObraLocalizacaoObraActualRow();
                    locActualRow.LicencaObraRow = CurrentLicencaObra;
                    locActualRow.ControloAutRow = caRow;
                    locActualRow.NumPolicia     = formLeitura.NumeroPolicia;
                    locActualRow.isDeleted      = 0;
                    // Dados:
                    Add_Row_LocalizacaoActual(locActualRow);
                    // GUI: adicionar `a lista:
                    Add_ViewLocalizacaoActual(dicionarioRow, locActualRow);
                    UpdateButtonState();
                }

                break;

            default:
                break;
            }
        }
Exemplo n.º 6
0
        public List <CorrespondenciaDocs> FilterPreviousIncorporations(List <CorrespondenciaDocs> corresp)
        {
            var desDictionary = corresp.ToDictionary(c => new IntGestDocRule.DocInPortoRecord()
            {
                IDExterno = c.EntidadeExterna.IDExterno, DataArquivo = c.EntidadeExterna.Timestamp, IDSistema = (int)c.EntidadeExterna.Sistema, IDTipoEntidade = (int)c.EntidadeExterna.Tipo
            }, c => c.EntidadeExterna);
            var correspDictionary = corresp.ToDictionary(c => c.EntidadeExterna, c => c);

            List <IntGestDocRule.DocInPortoRecord> diprecordsFiltered = null;
            var ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());

            try
            {
                diprecordsFiltered = IntGestDocRule.Current.FilterPreviousIncorporations(desDictionary.Keys.ToList(), ho.Connection);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                ho.Dispose();
            }

            var desFiltered = diprecordsFiltered.Where(rec => desDictionary.ContainsKey(rec)).Select(r => desDictionary[r]).ToList();

            return(desFiltered.Where(de => correspDictionary.ContainsKey(de)).Select(d => correspDictionary[d]).ToList());
        }
Exemplo n.º 7
0
        public void LoadData(GISADataset.FRDBaseRow FRDBase, IDbConnection conn)
        {
            this.CurrentFRDBase = FRDBase;

            FRDRule.Current.LoadDadosLicencasDeObras(GisaDataSetHelper.GetInstance(), CurrentFRDBase.ID, conn);
            var modRows = GisaDataSetHelper.GetInstance().IndexFRDCA.Cast <GISADataset.IndexFRDCARow>().Where(r => r.RowState != DataRowState.Unchanged).ToList();

            if (modRows.Count == 0)
            {
                FRDRule.Current.LoadConteudoEEstrutura(GisaDataSetHelper.GetInstance(), CurrentFRDBase.ID, conn);
            }

            var licenca = GisaDataSetHelper.GetInstance().LicencaObra.Cast <GISADataset.LicencaObraRow>().Where(r => r.IDFRDBase == CurrentFRDBase.ID).SingleOrDefault();

            var tipoTipLicencaObra = GisaDataSetHelper.GetInstance().TipoTipologias.Cast <GISADataset.TipoTipologiasRow>().Single(r => r.BuiltInName.Equals("PROCESSO_DE_OBRAS"));
            var caLicencaObra      = GisaDataSetHelper.GetInstance().IndexFRDCA.Cast <GISADataset.IndexFRDCARow>()
                                     .Where(idx => idx.RowState != DataRowState.Deleted && idx.IDFRDBase == CurrentFRDBase.ID && idx["Selector"] != DBNull.Value && idx.Selector == -1)
                                     .Select(idx => idx.ControloAutRow).SingleOrDefault(ca => ca.IDTipoNoticiaAut == (long)TipoNoticiaAut.TipologiaInformacional && ca.TipoTipologiasRow == tipoTipLicencaObra);

            if (licenca == null && caLicencaObra != null)
            {
                licenca                       = GisaDataSetHelper.GetInstance().LicencaObra.NewLicencaObraRow();
                licenca.FRDBaseRow            = CurrentFRDBase;
                licenca.TipoObra              = string.Empty;
                licenca.PropriedadeHorizontal = false;
                licenca.PHTexto               = string.Empty;
                licenca.Versao                = new byte[] { };
                licenca.isDeleted             = 0;
                GisaDataSetHelper.GetInstance().LicencaObra.AddLicencaObraRow(licenca);
            }

            CurrentLicencaObra = licenca;
        }
        public override void LoadData(DataRow CurrentDataRow, IDbConnection conn)
        {
            IsLoaded       = false;
            CurrentFRDBase = (GISADataset.FRDBaseRow)CurrentDataRow;

            var rhRow = CurrentFRDBase.NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().First();

            this.IDTipoNivelRelacionado = rhRow.IDTipoNivelRelacionado;

            string QueryFilter = "IDFRDBase=" + CurrentFRDBase.ID.ToString();

            ConfigureControlsVisibility(conn);

            if (this.IDTipoNivelRelacionado == (long)TipoNivelRelacionado.SD)
            {
                this.contInfLicencaObrasSD1.LoadData(CurrentFRDBase, conn);
            }
            else
            {
                this.contInfLicencaObras1.LoadData(CurrentFRDBase, conn);
            }

            if (GisaDataSetHelper.GetInstance().SFRDConteudoEEstrutura.Select(QueryFilter).Length != 0)
            {
                CurrentSFRDConteudoEEstrutura = (GISADataset.SFRDConteudoEEstruturaRow)(GisaDataSetHelper.GetInstance().SFRDConteudoEEstrutura.Select(QueryFilter)[0]);
            }
            else
            {
                CurrentSFRDConteudoEEstrutura = GisaDataSetHelper.GetInstance().SFRDConteudoEEstrutura.AddSFRDConteudoEEstruturaRow(CurrentFRDBase, "", "", new byte[] { }, 0);
            }

            IsLoaded = true;
        }
Exemplo n.º 9
0
		protected override DataRow[] GetRowDependencies(DataRow row)
		{
			var aeRow = (GISADataset.AutoEliminacaoRow)row;
            var dep = new List<string>();

            IDbConnection conn = GisaDataSetHelper.GetConnection();
            try
            {
                conn.Open();
                dep = RelatorioRule.Current.GetAutoEliminacaoAssociations (aeRow.ID, conn);
            }
            finally
            {
                conn.Close();
            }

            DataRow[] relatedRows = new DataRow[dep.Count];
            DataTable t = new DataTable();
            DataColumn c = new DataColumn("Value", typeof(string));
            t.Columns.Add(c);
            int cnt = 0;
            foreach (string v in dep)
            {
                DataRow dr = t.NewRow();
                dr[0] = v;
                t.Rows.Add(dr);
                relatedRows[cnt++] = dr;
            }

			//GISADataset.SFRDAvaliacaoRow[] relatedRows = (GISADataset.SFRDAvaliacaoRow[])(GisaDataSetHelper.GetInstance().SFRDAvaliacao. Select("IDAutoEliminacao = " + aeRow.ID.ToString()));

			return relatedRows;
		}
Exemplo n.º 10
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();
		}
Exemplo n.º 11
0
        protected virtual void DisplayFormaAutorizada(GISADataset.ControloAutDicionarioRow ControloAutDicionario)
        {
            Debug.Assert(TempIndexFRDCA != null);

            if (ControloAutDicionario.IDTipoControloAutForma != Convert.ToInt64(TipoControloAutForma.FormaAutorizada))
            {
                Debug.Assert(false, "CAD should always be Autorizado");

                GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                try
                {
                    DBAbstractDataLayer.DataAccessRules.ControloAutRule.Current.LoadFormaAutorizada(ControloAutDicionario.ControloAutRow.ID, GisaDataSetHelper.GetInstance(), ho.Connection);
                }
                finally
                {
                    ho.Dispose();
                }

                ControloAutDicionario = GISA.Model.ControloAutHelper.getFormaAutorizada(ControloAutDicionario.ControloAutRow);
            }

            ListViewItem li = ListView.Items.Add(ControloAutDicionario.DicionarioRow.Termo);

            li.Tag = TempIndexFRDCA;
            RaiseEventAddControloAut(li);
        }
Exemplo n.º 12
0
        public override void ViewToModel()
        {
            if (CurrentAutoEliminacao == null)
            {
                return;
            }

            // Elementos que tem a checkBox 'checked':
            long IDNivel;

            foreach (ListViewItem item in this.lstVwUnidadesFisicas.Items)
            {
                IDNivel = (long)item.Tag;
                GISADataset.NivelUnidadeFisicaRow[] nuf = (GISADataset.NivelUnidadeFisicaRow[])GisaDataSetHelper.GetInstance().NivelUnidadeFisica.Select("ID = " + IDNivel.ToString());
                if (nuf.Length == 0)
                {
                    if (item.Checked)
                    {
                        GISADataset.NivelUnidadeFisicaRow row = GisaDataSetHelper.GetInstance().NivelUnidadeFisica.NewNivelUnidadeFisicaRow(); // Linha nova
                        row.Eliminado = item.Checked;
                        row.ID        = IDNivel;
                        GisaDataSetHelper.GetInstance().NivelUnidadeFisica.AddNivelUnidadeFisicaRow(row);
                    }
                }
                else if (item.Tag != null)
                {
                    nuf[0].Eliminado = item.Checked;
                }
            }
            // Notas de eliminacao:
            CurrentAutoEliminacao.NotasEliminacao = txt_NotasEliminacao.Text;
        }
        private void LoadOperationsAndPermissions(GISADataset.DepositoRow depRow, ListViewItem item)
        {
            Debug.Assert(CurrentTrustee != null);

            var operations = GisaDataSetHelper.GetInstance().DepositoTipoOperation.Cast <GISADataset.DepositoTipoOperationRow>().ToList();

            operations.ForEach(opRow =>
            {
                item.SubItems.Add(string.Empty).Tag = opRow;
                int colIndex          = GetColumnIndex(opRow.TipoOperationRow.Name);
                var permissaoEfectiva = PermissoesHelper.CalculateEffectivePermissions(CurrentTrustee, opRow.TipoOperationRow, depRow);
                var tdpRow            = GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Cast <GISADataset.TrusteeDepositoPrivilegeRow>()
                                        .SingleOrDefault(r => r.IDDeposito == depRow.ID && r.IDTipoOperation == opRow.IDTipoOperation && r.IDTrustee == CurrentTrustee.ID);

                //PermissoesHelper.PopulatePermission(item, colIndex, tdpRow, permissaoEfectiva);
                if (permissaoEfectiva == PermissoesHelper.PermissionType.ExplicitGrant)
                {
                    item.SubItems[colIndex].Text = "Sim";
                }
                else
                {
                    item.SubItems[colIndex].Text = "Não";
                }

                if (GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Select(string.Format("IDTrustee={0} AND IDDeposito={1} AND IDTipoOperation={2}", CurrentTrustee.ID, depRow.ID, opRow.IDTipoOperation)).Length == 0)
                {
                    item.SubItems[colIndex].Font = PermissoesHelper.fontItalic;
                }
            });
        }
Exemplo n.º 14
0
        private void btnLocalConsultaManager_Click(object sender, System.EventArgs e)
        {
            FormLocalConsultaEditor formAutoEditor = new FormLocalConsultaEditor();
            IDbConnection           conn           = GisaDataSetHelper.GetConnection();

            try
            {
                conn.Open();
                RelatorioRule.Current.LoadLocaisConsulta(GisaDataSetHelper.GetInstance(), conn);
            }
            finally
            {
                conn.Close();
            }

            formAutoEditor.LoadData(GisaDataSetHelper.GetInstance().LocalConsulta.Select(string.Empty, "Designacao"), "Designacao");
            formAutoEditor.ShowDialog();

            long selectedLocalConsultaID = 0;

            if (cbLocalConsulta.SelectedValue == null)
            {
                selectedLocalConsultaID = long.MinValue;
            }
            else
            {
                selectedLocalConsultaID = (long)cbLocalConsulta.SelectedValue;
            }

            rebindToData();
            cbLocalConsulta.SelectedValue = selectedLocalConsultaID;
        }
        public override ArrayList GetCodigoCompletoCaminhoUnico(ListViewItem item)
        {
            GISADataset.RelacaoHierarquicaRow rhCurrentRow = null;
            ArrayList result = new ArrayList();

            foreach (BreadCrumbsPath.BreadCrumb bc in BreadCrumbsPath1.Path)
            {
                if (!(BreadCrumbsPath1.Path[0] == bc))
                {
                    // No caso de faltar uma parte do código returnar um arraylist vazio
                    if (GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", bc.idNivel, bc.idUpperNivel)).Length > 0)
                    {
                        rhCurrentRow = (GISADataset.RelacaoHierarquicaRow)(GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", bc.idNivel, bc.idUpperNivel))[0]);
                        result.Add(rhCurrentRow);
                    }
                    else
                    {
                        return(new ArrayList());
                    }
                }
            }

            GISADataset.NivelRow nRow = (GISADataset.NivelRow)(item.Tag);

            if (nRow.RowState != DataRowState.Detached)
            {
                if (GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", nRow.ID, BreadCrumbsPath1.getBreadCrumbsPathContextID)).Length > 0)
                {
                    rhCurrentRow = (GISADataset.RelacaoHierarquicaRow)(GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", nRow.ID, BreadCrumbsPath1.getBreadCrumbsPathContextID))[0]);
                    result.Add(rhCurrentRow);
                }
            }

            return(result);
        }
Exemplo n.º 16
0
		private void LoadNivelRoot(TreeView trvw)
		{
			long startTicks = DateTime.Now.Ticks;

			GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
			try
			{
				long[] edIDs = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadEntidadesDetentoras(GisaDataSetHelper.GetInstance(), ho.Connection);
				trvw.Nodes.Clear();
				GISADataset.NivelRow nRow = null;
				GISADataset.TipoNivelRelacionadoRow tnrRow = null;
				foreach (long edID in edIDs)
				{
					nRow = (GISADataset.NivelRow)(GisaDataSetHelper.GetInstance().Nivel.Select("ID=" + edID.ToString())[0]);                    
					tnrRow = (GISADataset.TipoNivelRelacionadoRow)(GisaDataSetHelper.GetInstance().TipoNivelRelacionado.Select(string.Format("ID={0}", TipoNivelRelacionado.ED))[0]);
					AddNivelDesignado(trvw.Nodes, nRow, null, tnrRow, ho.Connection);
				}
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex);
				throw;
			}
			finally
			{
				ho.Dispose();
			}

			Debug.WriteLine("<<LoadNivelRoot>>: " + new TimeSpan(DateTime.Now.Ticks - startTicks).ToString());
		}
Exemplo n.º 17
0
        private void AcceptNivelRow(GISADataset.NivelRow NivelRow)
        {
            // aceitar o drop apenas se se tratar de uma UF ainda não associada
            var nufRow  = NivelRow.GetNivelDesignadoRows()[0].GetNivelUnidadeFisicaRows()[0];
            var ufs     = GetUFInfo(NivelRow);
            var nufdRow = nufRow.GetNivelUnidadeFisicaDepositoRows().SingleOrDefault();

            if (nufdRow == null)
            {
                nufdRow = GisaDataSetHelper.GetInstance().NivelUnidadeFisicaDeposito.NewNivelUnidadeFisicaDepositoRow();
                nufdRow.NivelUnidadeFisicaRow = nufRow;
                nufdRow.DepositoRow           = CurrentDeposito;
                nufdRow.Versao    = new byte[] {};
                nufdRow.isDeleted = 0;
                GisaDataSetHelper.GetInstance().NivelUnidadeFisicaDeposito.AddNivelUnidadeFisicaDepositoRow(nufdRow);
                PopulateAssociacoes(ufs);
                ufsAssociadas.Add(ufs.ToList().Single());
            }
            else if (nufdRow.IDDeposito != CurrentDeposito.ID)
            {
                // ToDo: deixa-se substituir?
            }
            else if (nufdRow.IDDeposito == CurrentDeposito.ID && !ufsAssociadas.Contains(ufs.ToList().Single()))
            {
                PopulateAssociacoes(ufs);
                ufsAssociadas.Add(ufs.ToList().Single());
            }
        }
Exemplo n.º 18
0
        public override void LoadData(DataRow CurrentDataRow, IDbConnection conn)
        {
            IsLoaded       = false;
            CurrentFRDBase = (GISADataset.FRDBaseRow)CurrentDataRow;

            if (DragDropHandlerTipoInformacional == null)
            {
                DragDropHandlerTipoInformacional    = new ControloAutDragDrop(lstVwTipoInformacional, new TipoNoticiaAut[] { TipoNoticiaAut.TipologiaInformacional }, CurrentFRDBase);
                DragDropHandlerSubTipoInformacional = new ControloAutDragDrop(lstVwSubTipoInformacional, new TipoNoticiaAut[] { TipoNoticiaAut.TipologiaInformacional }, CurrentFRDBase);
                DragDropHandlerDiploma = new ControloAutDragDrop(lstVwDiplomaLegalRegulamentacao, new TipoNoticiaAut[] { TipoNoticiaAut.Diploma }, CurrentFRDBase);
                DragDropHandlerModelo  = new ControloAutDragDrop(lstVwModelo, new TipoNoticiaAut[] { TipoNoticiaAut.Modelo }, CurrentFRDBase);

                DragDropHandlerTipoInformacional.AddControloAut    += AddControloAut;
                DragDropHandlerSubTipoInformacional.AddControloAut += AddControloAut;
                DragDropHandlerDiploma.AddControloAut += AddControloAut;
                DragDropHandlerModelo.AddControloAut  += AddControloAut;
            }
            else
            {
                DragDropHandlerTipoInformacional.FRDBase    = CurrentFRDBase;
                DragDropHandlerSubTipoInformacional.FRDBase = CurrentFRDBase;
            }

            FRDRule.Current.LoadConteudoEEstrutura(GisaDataSetHelper.GetInstance(), CurrentFRDBase.ID, conn);

            OnShowPanel();
            IsLoaded = true;
        }
Exemplo n.º 19
0
        private void lstVwEstruturaDocs_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstVwEstruturaDocs.SelectedItems.Count == 1)
            {
                // é utilizada a primeira relação encontrada
                GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                try
                {
                    GISADataset.NivelRow nRow = null;
                    nRow = (GISADataset.NivelRow)(lstVwEstruturaDocs.SelectedItems[0].Tag);
                    panelInfoEPs1.BuildTree(nRow, ho.Connection);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    throw;
                }
                finally
                {
                    ho.Dispose();
                }
            }
            else if (lstVwEstruturaDocs.SelectedItems.Count == 0)
            {
                panelInfoEPs1.ClearAll();
            }

            UpdateToolBarButtons();
        }
Exemplo n.º 20
0
        private void CreateNewRelation(GISADataset.ControloAutRow row)
        {
            if (row == null || PresentInIndex(row))
            {
                return;
            }

            GISADataset.IndexFRDCARow   IndexFRDCARow         = null;
            GISADataset.IndexFRDCARow[] IndexFRDCADeletedRows = null;

            // se a row de IndexFRDCA já existir em memória como Deleted resuscitamo-la
            IndexFRDCADeletedRows = (GISADataset.IndexFRDCARow[])(GisaDataSetHelper.GetInstance().IndexFRDCA.Select(string.Format("IDFRDBase = {0} AND IDControloAut = {1}", CurrentFRDBase.ID, row.ID), string.Empty, DataViewRowState.Deleted));
            if (IndexFRDCADeletedRows.Length > 0)
            {
                IndexFRDCARow = IndexFRDCADeletedRows[0];
                IndexFRDCARow.RejectChanges();
            }
            else
            {
                IndexFRDCARow                = GisaDataSetHelper.GetInstance().IndexFRDCA.NewIndexFRDCARow();
                IndexFRDCARow.FRDBaseRow     = CurrentFRDBase;
                IndexFRDCARow.ControloAutRow = row;
                IndexFRDCARow["Selector"]    = DBNull.Value;
                GisaDataSetHelper.GetInstance().IndexFRDCA.AddIndexFRDCARow(IndexFRDCARow);
            }
        }
Exemplo n.º 21
0
        private void btn_AddRequerenteInicial_Click(object sender, EventArgs e)
        {
            FormLeitura_Designacao formLeitura = new FormLeitura_Designacao();

            formLeitura.Title      = "Requerente/proprietário inicial";
            formLeitura.LabelTitle = "Nome do requerente/proprietário";
            GISADataset.LicencaObraRequerentesRow requerente = null;

            switch (formLeitura.ShowDialog())
            {
            case DialogResult.OK:
                if (!existe_LicencaObraRequerenteActual(formLeitura.Designacao))
                {
                    requerente           = GisaDataSetHelper.GetInstance().LicencaObraRequerentes.NewLicencaObraRequerentesRow();
                    requerente.IDFRDBase = CurrentLicencaObra.IDFRDBase;
                    requerente.Nome      = formLeitura.Designacao;
                    // TIPO = 'INICIAL'
                    requerente.Tipo      = "INICIAL";
                    requerente.isDeleted = 0;
                    // Dados:
                    GisaDataSetHelper.GetInstance().LicencaObraRequerentes.AddLicencaObraRequerentesRow(requerente);
                    // GUI:
                    ListViewItem item = this.lstVwRequerente.Items.Add(requerente.Nome);
                    item.Tag = requerente;
                }

                break;
            }
        }
Exemplo n.º 22
0
        private void ChangePermission(GISADataset.TrusteeRow user, ListViewItem item, int colIndex)
        {
            GISADataset.TipoFunctionRow tipoFunction = (GISADataset.TipoFunctionRow)item.Tag;
            GISADataset.TipoOperationRow tipoOperation = (GISADataset.TipoOperationRow)(GisaDataSetHelper.GetInstance().TipoOperation.Select(string.Format("Name='{0}'", lstvwPermissoes.Columns[colIndex].Text))[0]);

            string query = "IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction = {2} AND IDTipoOperation = {3}";
            query = string.Format(query, user.ID, tipoFunction.IDTipoFunctionGroup, tipoFunction.idx, tipoOperation.ID);

            GISADataset.TrusteePrivilegeRow[] trusteePrivileges = null;
            trusteePrivileges = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(query));

            // alterar permissões no dataset
            if (trusteePrivileges.Length > 0)
            {
                if (trusteePrivileges[0].IsGrant)
                    trusteePrivileges[0].IsGrant = false;
                else
                    trusteePrivileges[0].Delete();
            }
            else
            {
                trusteePrivileges = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(query, "", DataViewRowState.Deleted));
                if (trusteePrivileges.Length > 0)
                {
                    trusteePrivileges[0].RejectChanges();
                    trusteePrivileges[0].IsGrant = true;
                }
                else
                    GisaDataSetHelper.GetInstance().TrusteePrivilege.AddTrusteePrivilegeRow(user, tipoFunction.IDTipoFunctionGroup, tipoFunction.idx, tipoOperation.ID, true, new byte[] { }, 0);
            }

            // popular as alterações
            GISADataset.FunctionOperationRow functionOperation = (GISADataset.FunctionOperationRow)(GisaDataSetHelper.GetInstance().FunctionOperation.Select(string.Format("IDTipoFunctionGroup={0} AND IdxTipoFunction={1} AND IDTipoOperation={2}", tipoFunction.IDTipoFunctionGroup, tipoFunction.idx, tipoOperation.ID))[0]);

            PermissoesHelper.PermissionType permissaoEfectiva = PermissoesHelper.CalculateEffectivePermissions(CurrentTrusteeRow, functionOperation);

            if (permissaoEfectiva == PermissoesHelper.PermissionType.ExplicitGrant)
                item.SubItems[functionOperation.TipoOperationRow.ID].Text = "Sim";
            else
                item.SubItems[functionOperation.TipoOperationRow.ID].Text = "Não";

            GISADataset.TrusteePrivilegeRow[] tpRows = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(string.Format("IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction = {2} AND IDTipoOperation = {3}", user.ID, functionOperation.IDTipoFunctionGroup, functionOperation.IdxTipoFunction, functionOperation.IDTipoOperation)));

            if (tpRows.Length == 0)
            {
                tpRows = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(string.Format("IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction = {2} AND IDTipoOperation = {3}", user.ID, functionOperation.IDTipoFunctionGroup, functionOperation.IdxTipoFunction, functionOperation.IDTipoOperation), "", DataViewRowState.Deleted));

                if (tpRows.Length == 0)
                    item.SubItems[colIndex].Font = PermissoesHelper.fontItalic;
                else
                    item.SubItems[colIndex].Font = PermissoesHelper.fontBoldItalic;
            }
            else
            {
                if (tpRows[0].RowState == DataRowState.Modified && !(tpRows[0].IsGrant ^ (bool)(tpRows[0]["IsGrant", DataRowVersion.Original])))
                    item.SubItems[colIndex].Font = PermissoesHelper.fontRegular;
                else
                    item.SubItems[colIndex].Font = PermissoesHelper.fontBold;
            }
        }
Exemplo n.º 23
0
        private void btn_Add_AtestadoHab_Click(object sender, EventArgs e)
        {
            FormLeitura_Designacao formLeitura = new FormLeitura_Designacao();

            formLeitura.Title      = "Atestado de Habitabilidade";
            formLeitura.LabelTitle = "Código do atestado";
            GISADataset.LicencaObraAtestadoHabitabilidadeRow atestado = null;
            switch (formLeitura.ShowDialog())
            {
            case DialogResult.OK:
                if (!existe_AtestadoHab(formLeitura.Designacao))
                {
                    atestado = GisaDataSetHelper.GetInstance().LicencaObraAtestadoHabitabilidade.NewLicencaObraAtestadoHabitabilidadeRow();
                    atestado.LicencaObraRow = CurrentLicencaObra;
                    atestado.Codigo         = formLeitura.Designacao;
                    atestado.isDeleted      = 0;
                    // Dados:
                    GisaDataSetHelper.GetInstance().LicencaObraAtestadoHabitabilidade.AddLicencaObraAtestadoHabitabilidadeRow(atestado);
                    // GUI:
                    ListViewItem item = this.lstVwAtestadoHab.Items.Add(atestado.Codigo);
                    item.Tag = atestado;
                }
                break;
            }
        }
Exemplo n.º 24
0
        private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            var currentRow = dataGridView1.Rows[e.RowIndex];

            if (currentRow == dataGridView1_MouseMove_previousRow)
            {
                return;
            }

            dataGridView1_MouseMove_previousRow = currentRow;

            // See if we have a valid item under mouse pointer
            if (currentRow != null)
            {
                var IDNivelUF = long.Parse(currentRow.Cells[ID].Value.ToString());
                LoadUFRelacionada(IDNivelUF);
                var ufRow = GisaDataSetHelper.GetInstance().Nivel.Cast <GISADataset.NivelRow>().Single(r => r.ID == IDNivelUF);
                currentRow.Cells[e.ColumnIndex].ToolTipText = UnidadesFisicasHelper.GetConteudoInformacional(GisaDataSetHelper.GetInstance(), ufRow);
            }
        }
Exemplo n.º 25
0
        // Adicionar uma localizacao antiga
        private void btn_AddLocalizacaoAntiga_Click(object sender, EventArgs e)
        {
            FormLeituraLocalizacaoNumPolicia formLeitura = new FormLeituraLocalizacaoNumPolicia();

            formLeitura.Title          = "Designação antiga do local";
            formLeitura.ModoTextoLivre = true;
            GISADataset.LicencaObraLocalizacaoObraAntigaRow locAntigaRow = null;

            string designacao    = string.Empty;
            string numeroPolicia = string.Empty;

            switch (formLeitura.ShowDialog())
            {
            case DialogResult.OK:
                designacao    = formLeitura.Designacao;
                numeroPolicia = formLeitura.NumeroPolicia;
                if (!existe_LicencaObraLocalizacaoObraAntiga(designacao, numeroPolicia))
                {
                    locAntigaRow = GisaDataSetHelper.GetInstance().LicencaObraLocalizacaoObraAntiga.NewLicencaObraLocalizacaoObraAntigaRow();
                    locAntigaRow.LicencaObraRow = CurrentLicencaObra;
                    locAntigaRow.NomeLocal      = designacao;
                    locAntigaRow.NumPolicia     = numeroPolicia;
                    locAntigaRow.isDeleted      = 0;
                    GisaDataSetHelper.GetInstance().LicencaObraLocalizacaoObraAntiga.AddLicencaObraLocalizacaoObraAntigaRow(locAntigaRow);
                    // GUI: adicionar `a lista:
                    Add_ViewLocalizacaoAntiga(locAntigaRow);
                }

                break;

            default:
                break;
            }
        }
Exemplo n.º 26
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            FormUserGroups form = new FormUserGroups();

            byte[] Versao = null;
            if (form.ShowDialog() == DialogResult.OK)
            {
                this.Cursor = Cursors.WaitCursor;
                GISADataset.TrusteeRow tRow    = null;
                List <long>            tRowIDs = new List <long>();
                foreach (ListViewItem item in form.lstVwTrustees.SelectedItems)
                {
                    tRow = (GISADataset.TrusteeRow)item.Tag;
                    // verificar se o utilizador foi anteriormente adicionado ao grupo
                    if (GisaDataSetHelper.GetInstance().UserGroups.Select(string.Format("IDUser={0} AND IDGroup={1}", (CurrentTrusteeRow.GetTrusteeUserRows()[0]).ID.ToString(), (tRow.GetTrusteeGroupRows()[0]).ID.ToString())).Length == 0)
                    {
                        tRowIDs.Add(tRow.ID);
                        GisaDataSetHelper.GetInstance().UserGroups.AddUserGroupsRow(CurrentTrusteeRow.GetTrusteeUserRows()[0], tRow.GetTrusteeGroupRows()[0], Versao, 0);
                    }
                }

                PersistencyHelper.save();
                PersistencyHelper.cleanDeletedData();
                EnumerateMembership(CurrentTrusteeRow);
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 27
0
		private void CADDataRowChangedHandler(object sender, DataRowChangeEventArgs e)
		{
			if (e.Action == DataRowAction.Add)
			{
				GISADataset.ControloAutDicionarioRow changedCadRow = null;
				changedCadRow = (GISADataset.ControloAutDicionarioRow)e.Row;
				GISADataset.ControloAutRow changedCaRow = null;
				changedCaRow = changedCadRow.ControloAutRow;

				Debug.WriteLine("[CONTROLO AUT DICIONARIO ADDED]" + new StackFrame(true).ToString());

				Trace.Assert(e.Row is GISADataset.ControloAutDicionarioRow);

				foreach (ListViewItem item in lstVwIndexacao.Items)
				{
					GISADataset.IndexFRDCARow ifrdcaRow = null;
					ifrdcaRow = (GISADataset.IndexFRDCARow)item.Tag;

					if (changedCaRow == ifrdcaRow.ControloAutRow)
					{
						// actualizar a interface com a forma autorizada do CA em causa
						foreach (GISADataset.ControloAutDicionarioRow cadRow in GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0}", changedCaRow.ID)))
						{
							if (cadRow.TipoControloAutFormaRow.ID == Convert.ToInt64(TipoControloAutForma.FormaAutorizada))
							{
								lstVwIndexacao.BeginUpdate();
								item.SubItems[0].Text = cadRow.DicionarioRow.Termo;
								lstVwIndexacao.EndUpdate();
								break;
							}
						}
					}
				}
			}
		}
Exemplo n.º 28
0
        private void RetrieveSelection(FormControloAutRel frm, DataRow relRow)
        {
            try
            {
                if (relRow != null)                 // edição
                {
                    frm.SetEditMode();
                }

                frm.ShowDialog();

                GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                try
                {
                    LoadData(CurrentControloAut, ho.Connection);
                    ModelToView();
                }
                finally
                {
                    ho.Dispose();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                throw ex;
            }
        }
Exemplo n.º 29
0
        public override void LoadData()
        {
            if (CurrentContext.Movimento == null)
            {
                CurrentMovimento = null;
                return;
            }

            CurrentMovimento = CurrentContext.Movimento;

            GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetTempConnection());
            try
            {
                documentos = MovimentoRule.Current.GetDocumentos(CurrentMovimento.ID, GisaDataSetHelper.GetInstance(), ho.Connection);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                throw;
            }
            finally
            {
                ho.Dispose();
            }
        }
Exemplo n.º 30
0
		private void caList_BeforeNewListSelection(object sender, BeforeNewSelectionEventArgs e)
		{
			if (e.ItemToBeSelected.ListView == null || (e.ItemToBeSelected != null && e.ItemToBeSelected.ListView == null))
			{
				relacaoCA.ContextNivelRow = null;
			}
			else
			{
				GISADataset.ControloAutRow caRow = null;
				caRow = ((GISADataset.ControloAutDicionarioRow)e.ItemToBeSelected.Tag).ControloAutRow;

				IDbConnection conn = GisaDataSetHelper.GetConnection();
				try
				{
					conn.Open();

					DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadNivelByControloAut(caRow.ID, GisaDataSetHelper.GetInstance(), conn);
				}
				catch (Exception ex)
				{
					Trace.WriteLine(ex);
					throw;
				}
				finally
				{
					conn.Close();
				}
				relacaoCA.ContextNivelRow = caRow.GetNivelControloAutRows()[0].NivelRow;
			}

			RefreshButtonState(e.ItemToBeSelected);
		}