Exemplo n.º 1
0
        public override void ModelToView()
        {
            IsPopulated = false;

            ControloRevisoes1.ControloAutores1.LoadAndPopulateAuthors();
            if (SessionHelper.GetGisaPrincipal().TrusteeUserAuthor != null)
            {
                ControloRevisoes1.ControloAutores1.SelectedAutor = SessionHelper.GetGisaPrincipal().TrusteeUserAuthor.TrusteeRow;
            }

            txtIdentificadorRegisto.Text = CurrentControloAut.ID.ToString();

            if (!(CurrentControloAut.IsRegrasConvencoesNull()))
            {
                txtRegrasConvencoes.Text = CurrentControloAut.RegrasConvencoes;
            }
            else
            {
                txtRegrasConvencoes.Text = "";
            }

            if (!(CurrentControloAut.IsObservacoesNull()))
            {
                txtObservacoes.Text = CurrentControloAut.Observacoes;
            }
            else
            {
                txtObservacoes.Text = "";
            }

            lstVwIdentidadeInstituicoes.Items.Clear();
            foreach (GISADataset.ControloAutRelRow carRow in GisaDataSetHelper.GetInstance().ControloAutRel.Select(QueryFilter))
            {
                AddIdentidadeInstituicao(carRow);
            }

            UpdateLstVwIdentidadeInstituicoesButtonsState();

            // populate datas criacao history
            lstVwDataCriacaoRevisao.Items.Clear();
            ListViewItem item = null;

            foreach (GISADataset.ControloAutDataDeDescricaoRow cadddRow in GisaDataSetHelper.GetInstance().ControloAutDataDeDescricao.Select(QueryFilter, "DataEdicao DESC"))
            {
                item = lstVwDataCriacaoRevisao.Items.Add("");
                item.SubItems.AddRange(new string[] { "", "", "" });
                item.SubItems[colDataRegisto.Index].Text   = cadddRow.DataEdicao.ToString();
                item.SubItems[colDataDescricao.Index].Text = string.Format("{0:yyyy}-{0:MM}-{0:dd}", cadddRow.DataAutoria);

                if (SessionHelper.AppConfiguration.GetCurrentAppconfiguration().TipoServer.ID == Convert.ToInt64(TipoServer.ClienteServidor))
                {
                    item.SubItems[colOperator.Index].Text = cadddRow.TrusteeUserRowByTrusteeUserControloAutDataDeDescricao.TrusteeRow.Name;
                }

                if (!cadddRow.IsIDTrusteeAuthorityNull())
                {
                    item.SubItems[colAuthority.Index].Text = cadddRow.TrusteeUserRowByTrusteeUserControloAutDataDeDescricaoAuthority.TrusteeRow.Name;
                }

                item.Tag = cadddRow;
            }

            lstVwDataCriacaoRevisao.SelectedItems.Clear();
            // the following should ensure the list was scrolled all the
            // way to the bottom. it doesn't always not working though.
            if (lstVwDataCriacaoRevisao.Items.Count > 0)
            {
                lstVwDataCriacaoRevisao.EnsureVisible(0);
            }

            // populate linguas
            ArrayList Iso639Data = new ArrayList();

            GISADataset.Iso639Row i639Row = (GISADataset.Iso639Row)(GisaDataSetHelper.GetInstance().Iso639.NewRow());
            i639Row.ID = -1;
            i639Row.LanguageNameEnglish = "";
            Iso639Data.Add(i639Row);
            Iso639Data.AddRange(GisaDataSetHelper.GetInstance().Iso639.Select());
            cbLingua.DataSource    = Iso639Data;
            cbLingua.DisplayMember = "LanguageNameEnglish";
            cbLingua.ValueMember   = "ID";
            try
            {
                cbLingua.SelectedValue = CurrentControloAut.IDIso639p2;
            }
            catch (StrongTypingException)
            {
                cbLingua.SelectedValue = -1;
            }

            // populate alfabetos
            ArrayList Iso15924Data = new ArrayList();

            GISADataset.Iso15924Row i15924Row = (GISADataset.Iso15924Row)(GisaDataSetHelper.GetInstance().Iso15924.NewRow());
            i15924Row.ID = -1;
            i15924Row.ScriptNameEnglish = "";
            Iso15924Data.Add(i15924Row);
            Iso15924Data.AddRange(GisaDataSetHelper.GetInstance().Iso15924.Select());
            cbAlfabeto.DataSource    = Iso15924Data;
            cbAlfabeto.DisplayMember = "ScriptNameEnglish";
            cbAlfabeto.ValueMember   = "ID";
            try
            {
                cbAlfabeto.SelectedValue = CurrentControloAut.IDIso15924;
            }
            catch (StrongTypingException)
            {
                cbAlfabeto.SelectedValue = -1;
            }

            // populate checkboxes
            chkDefinitivo.Checked = CurrentControloAut.Autorizado;
            chkCompleta.Checked   = CurrentControloAut.Completo;
            IsPopulated           = true;
        }