// garantir que o tipo de quantidade da descrição física existe aquando da sua gravação na BD private void TipoAcondicionamentoIsBeingUsedByOthers(GISA.Model.PersistencyHelper.PreConcArguments args) { GISA.Model.PersistencyHelper.ManageDescFisicasPreConcArguments mcfPca = null; mcfPca = (GISA.Model.PersistencyHelper.ManageDescFisicasPreConcArguments)args; GISADataset.FRDBaseRow frd = (GISADataset.FRDBaseRow)(GisaDataSetHelper.GetInstance().FRDBase.Select("ID=" + mcfPca.frdID.ToString())[0]); ArrayList quantList = mcfPca.quant; int nTQuant = 0; GISADataset.TipoAcondicionamentoRow row = null; try { foreach (long quant in quantList) { row = (GISADataset.TipoAcondicionamentoRow)(GisaDataSetHelper.GetInstance().TipoAcondicionamento.Select("ID=" + quant.ToString(), "", DataViewRowState.Deleted)[0]); nTQuant = FRDRule.Current.CountUFDimensoesAcumuladas(quant, mcfPca.tran); System.Data.DataSet tempgisaBackup1 = mcfPca.gisaBackup; PersistencyHelper.BackupRow(ref tempgisaBackup1, row); mcfPca.gisaBackup = tempgisaBackup1; if (nTQuant > 0) { row.RejectChanges(); mcfPca.aResult = PersistencyHelper.ManageDescFisicasPreConcArguments.ActionResult.quantidadeUsedByOthers; } } } catch (Exception ex) { Trace.WriteLine(ex); throw ex; } }
protected override DataRow GetUpdatedDataRow(DataRow row, string NewValue) { GISADataset.TipoAcondicionamentoRow TQRow = (GISADataset.TipoAcondicionamentoRow)row; TQRow.Designacao = NewValue; return TQRow; }
protected override DataRow[] GetRowDependencies(DataRow row) { GISADataset.TipoAcondicionamentoRow taRow = (GISADataset.TipoAcondicionamentoRow)row; GISADataset.SFRDUFDescricaoFisicaRow[] relatedRowsUF = (GISADataset.SFRDUFDescricaoFisicaRow[])(GisaDataSetHelper.GetInstance().SFRDUFDescricaoFisica. Select("IDTipoAcondicionamento = " + taRow.ID.ToString())); return relatedRowsUF; }
private void LoadContents() { GISADataset.TipoAcondicionamentoRow all = (GisaDataSetHelper.GetInstance()).TipoAcondicionamento.NewTipoAcondicionamentoRow(); all.ID = 0; all.Designacao = "Todos"; DataRow[] DataRows = GisaDataSetHelper.GetInstance().TipoAcondicionamento.Select(); GISADataset.TipoAcondicionamentoRow[] DataRowsEx = null; DataRowsEx = new GISADataset.TipoAcondicionamentoRow[DataRows.Length + 1]; DataRowsEx[0] = all; Array.Copy(DataRows, 0, DataRowsEx, 1, DataRows.Length); this.cbTipoAcond.DataSource = DataRowsEx; this.cbTipoAcond.DisplayMember = "Designacao"; this.cbTipoAcond.ValueMember = "ID"; this.cbAssociacoes.SelectedItem = this.cbAssociacoes.Items[0]; }
private void LoadContents() { GISADataset.TipoAcondicionamentoRow all = (GisaDataSetHelper.GetInstance()).TipoAcondicionamento.NewTipoAcondicionamentoRow(); all.ID = 0; all.Designacao = "Todos"; DataRow[] DataRows = GisaDataSetHelper.GetInstance().TipoAcondicionamento.Select(); GISADataset.TipoAcondicionamentoRow[] DataRowsEx = null; DataRowsEx = new GISADataset.TipoAcondicionamentoRow[DataRows.Length + 1]; DataRowsEx[0] = all; Array.Copy(DataRows, 0, DataRowsEx, 1, DataRows.Length); this.cbTipoAcond.DataSource = DataRowsEx; this.cbTipoAcond.DisplayMember = "Designacao"; this.cbTipoAcond.ValueMember = "ID"; this.cbAssociacoes.SelectedItem = this.cbAssociacoes.Items[0]; }
// Antes de adicionar um novo elemento é verificado se foi eliminado um com uma designação igual. Se for esse o caso, a linha apagada é // reaproveitada evitando possíveis futuros conflitos aquando da gravação de dados protected override DataRow GetNewDataRow(string Value) { GISADataset.TipoAcondicionamentoRow row = null; GISADataset.TipoAcondicionamentoRow[] deletedRows = (GISADataset.TipoAcondicionamentoRow[])(GisaDataSetHelper.GetInstance().TipoAcondicionamento.Select(string.Format("Designacao='{0}'", Value), "", DataViewRowState.Deleted)); GISADataset.TipoAcondicionamentoRow[] currentRows = (GISADataset.TipoAcondicionamentoRow[])(GisaDataSetHelper.GetInstance().TipoAcondicionamento.Select(string.Format("Designacao='{0}'", Value))); if (deletedRows.Length > 0) { deletedRows[0].RejectChanges(); row = deletedRows[0]; } else if (currentRows.Length > 0) { // Já existe uma row com esta designacao. Não criamos nem ressuscitamos nenhuma. row = null; } else { row = GisaDataSetHelper.GetInstance().TipoAcondicionamento.NewTipoAcondicionamentoRow(); row.Designacao = Value; GisaDataSetHelper.GetInstance().TipoAcondicionamento.AddTipoAcondicionamentoRow(row); } return row; }
private void ExecuteQuery(MasterPanelPesquisaUF MasterPanel) { ToolBar_ButtonClick(this, new ToolBarButtonClickEventArgs(ToolBarButton2)); List <string> resultadosDaPesquisa = new List <string>(); try { ((frmMain)TopLevelControl).EnterWaitMode(); this.lblFuncao.Text = string.Format("Resultados da pesquisa (em curso)"); this.lblFuncao.Update(); GisaDataSetHelper.ManageDatasetConstraints(false); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { // TODO: Considerar retirar a dependência com Lucene.Net para fazer a validação dos campos: nem todos são validados.... UnidadeFisicaSearch ufSearch = new UnidadeFisicaSearch(); Lucene.Net.Analysis.Analyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30); QueryParser qp = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, string.Empty, analyzer); qp.AllowLeadingWildcard = true; StringBuilder errorMessage = new StringBuilder(); ufSearch.Numero = Helper.AddFieldToSearch(qp, "Código Parcial", MasterPanelPesquisaUF.txtCdReferencia.Text, ref errorMessage); ufSearch.Designacao = Helper.AddFieldToSearch(qp, "Designação", MasterPanelPesquisaUF.txtDesignacao.Text, ref errorMessage); ufSearch.Cota = Helper.AddFieldToSearch(qp, "Cota", Helper.EscapeSpecialCharactersCotaDocumento(MasterPanelPesquisaUF.txtCota.Text.ToLower()), ref errorMessage); ufSearch.CodigoBarras = Helper.AddFieldToSearch(qp, "CodigoBarras", MasterPanelPesquisaUF.txtCodigoBarras.Text, ref errorMessage); ufSearch.ConteudoInformacional = Helper.AddFieldToSearch(qp, "Conteúdo Informacional", MasterPanelPesquisaUF.txtConteudoInformacional.Text, ref errorMessage); // Nota: a combo MasterPanelPesquisaUF.cbTipoAcond contem uma lista de GISADataset.TipoAcondicionamentoRow GISADataset.TipoAcondicionamentoRow tipoAcondRow = (GISADataset.TipoAcondicionamentoRow)MasterPanelPesquisaUF.cbTipoAcond.SelectedItem; string tipoUnidadeFisica = tipoAcondRow.Designacao; if (tipoUnidadeFisica.ToLower().Equals("todos")) { tipoUnidadeFisica = ""; } else if (tipoUnidadeFisica.ToLower().Equals("<desconhecido>")) { tipoUnidadeFisica = "desconhecido"; } ufSearch.TipoUnidadeFisica = Helper.AddFieldToSearch(qp, "Tipo de Unidade Física", tipoUnidadeFisica, ref errorMessage); ufSearch.GuiaIncorporacao = Helper.AddFieldToSearch(qp, "Guia incorporação", MasterPanelPesquisaUF.txtGuiaIncorporacao.Text, ref errorMessage); ufSearch.Eliminado = MasterPanelPesquisaUF.chkFiltroUFsEliminadas.Checked ? "" : "nao"; if (MasterPanelPesquisaUF.cdbDataInicio.Checked) { ufSearch.DataProducaoInicioDoInicio = MasterPanelPesquisaUF.cdbDataInicio.GetStandardMaskDate.ToString("yyyyMMdd"); } if (MasterPanelPesquisaUF.cdbDataFim.Checked) { ufSearch.DataProducaoFimDoInicio = MasterPanelPesquisaUF.cdbDataFim.GetStandardMaskDate.ToString("yyyyMMdd"); } if (MasterPanelPesquisaUF.cdbInicioDoFim.Checked) { ufSearch.DataProducaoInicioDoFim = MasterPanelPesquisaUF.cdbInicioDoFim.GetStandardMaskDate.ToString("yyyyMMdd"); } if (MasterPanelPesquisaUF.cdbFimDoFim.Checked) { ufSearch.DataProducaoFimDoFim = MasterPanelPesquisaUF.cdbFimDoFim.GetStandardMaskDate.ToString("yyyyMMdd"); } if (errorMessage.Length > 0) { MessageBox.Show("O(s) campo(s) seguinte(s) tem(êm) valor(es) incorrecto(s): " + System.Environment.NewLine + errorMessage.ToString()); return; } resultadosDaPesquisa.AddRange(SearchImpl.search(ufSearch.ToString(), "unidadeFisica")); // filtragens adicionais sobre os resultados de pesquisa string operador = string.Empty; int anoEdicaoInicio = int.MinValue; int mesEdicaoInicio = int.MinValue; int diaEdicaoInicio = int.MinValue; int anoEdicaoFim = int.MinValue; int mesEdicaoFim = int.MinValue; int diaEdicaoFim = int.MinValue; long IDNivel = long.MinValue; int assoc = int.MinValue; operador = MasterPanelPesquisaUF.txtOperador.Text; assoc = MasterPanelPesquisaUF.cbAssociacoes.SelectedIndex; if (MasterPanelPesquisaUF.cdbDataEdicaoInicio.Checked) { anoEdicaoInicio = MasterPanelPesquisaUF.cdbDataEdicaoInicio.Year; mesEdicaoInicio = MasterPanelPesquisaUF.cdbDataEdicaoInicio.Month; diaEdicaoInicio = MasterPanelPesquisaUF.cdbDataEdicaoInicio.Day; } if (MasterPanelPesquisaUF.cdbDataEdicaoFim.Checked) { anoEdicaoFim = MasterPanelPesquisaUF.cdbDataEdicaoFim.Year; mesEdicaoFim = MasterPanelPesquisaUF.cdbDataEdicaoFim.Month; diaEdicaoFim = MasterPanelPesquisaUF.cdbDataEdicaoFim.Day; } if (MasterPanelPesquisaUF.chkEstruturaArquivistica.Checked && MasterPanelPesquisaUF.cnList.SelectedNivelRow != null) { IDNivel = MasterPanelPesquisaUF.cnList.SelectedNivelRow.ID; } PesquisaUFList1.SearchServerIDs = resultadosDaPesquisa; PesquisaUFList1.operador = operador; PesquisaUFList1.anoEdicaoInicio = anoEdicaoInicio; PesquisaUFList1.mesEdicaoInicio = mesEdicaoInicio; PesquisaUFList1.diaEdicaoInicio = diaEdicaoInicio; PesquisaUFList1.anoEdicaoFim = anoEdicaoFim; PesquisaUFList1.mesEdicaoFim = mesEdicaoFim; PesquisaUFList1.diaEdicaoFim = diaEdicaoFim; PesquisaUFList1.IDNivel = IDNivel; PesquisaUFList1.assoc = assoc; PesquisaUFList1.NewSearch = true; resultNumber = 0; PesquisaUFList1.ReloadList(); PesquisaUFList1.NewSearch = false; resultNumber = PesquisaUFList1.NrResults; PesquisaUFList1.Focus(); Trace.WriteLine(string.Format("Found {0} results.", resultNumber)); this.lblFuncao.Text = string.Format("Resultados da pesquisa ({0} {1})", resultNumber, ((resultNumber == 1) ? "descrição" : "descrições")); UpdateToolBarButtons(); } catch (Exception ex) { resultNumber = 0; Trace.WriteLine(ex); this.lblFuncao.Text = string.Format("Resultados da pesquisa"); } finally { ho.Dispose(); } GisaDataSetHelper.ManageDatasetConstraints(true); } catch (Exception Ex) { Trace.WriteLine(Ex); this.lblFuncao.Text = string.Format("Resultados da pesquisa"); } finally { ((frmMain)TopLevelControl).LeaveWaitMode(); } }
private void btnMaterialManager_Click(object sender, System.EventArgs e) { if (CurrentUFFRDBase.RowState == DataRowState.Detached) { MessageBox.Show("A unidade física selecionada foi apagada por outro utilizador motivo pelo qual " + System.Environment.NewLine + "não é possível editar os Tipos de Material.", "Unidade física apagada", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } IDbConnection conn = GisaDataSetHelper.GetConnection(); try { conn.Open(); UFRule.Current.LoadTipoAcondicionamento(GisaDataSetHelper.GetInstance(), conn); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { conn.Close(); } FormMateriaisEditor formMatEditor = new FormMateriaisEditor(); formMatEditor.LoadData(GisaDataSetHelper.GetInstance().TipoAcondicionamento.Select("NOT Designacao = '<Desconhecido>'"), "Designacao"); formMatEditor.ShowDialog(); GISA.Model.PersistencyHelper.ManageDescFisicasPreConcArguments args = new GISA.Model.PersistencyHelper.ManageDescFisicasPreConcArguments(); args.frdID = CurrentUFFRDBase.ID; ArrayList rowList = new ArrayList(); foreach (DataRow row in GisaDataSetHelper.GetInstance().Tables["TipoAcondicionamento"].Select("", "", DataViewRowState.Deleted)) { rowList.Add(row["ID", DataRowVersion.Original]); } args.quant = rowList; PersistencyHelper.SaveResult successfulSave = PersistencyHelper.save(TipoAcondicionamentoIsBeingUsedByOthers, args); PersistencyHelper.cleanDeletedData(); if (args.aResult == PersistencyHelper.ManageDescFisicasPreConcArguments.ActionResult.quantidadeUsedByOthers) { MessageBox.Show("Um ou mais tipos de acondicionamento não puderam ser" + Environment.NewLine + "removidos por estarem atualmente em uso.", "Remoção de Elementos", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (successfulSave == PersistencyHelper.SaveResult.successful) { GISA.Search.Updater.updateUnidadeFisica(CurrentUFFRDBase.NivelRow.ID); } GISADataset.TipoAcondicionamentoRow selectedTipoAcondicionamento = (GISADataset.TipoAcondicionamentoRow)cbTipo.SelectedItem; cbTipo.Items.Clear(); cbTipo.DisplayMember = "Designacao"; cbTipo.Items.AddRange(GisaDataSetHelper.GetInstance().TipoAcondicionamento.Select("", "Designacao")); if (selectedTipoAcondicionamento != null) { cbTipo.SelectedItem = selectedTipoAcondicionamento; } else { cbTipo.SelectedItem = (GISADataset.TipoAcondicionamentoRow)(GisaDataSetHelper.GetInstance().TipoAcondicionamento.Select(string.Format("ID={0:d}", TipoAcondicionamento.Pasta))[0]); } }