示例#1
0
        public ArrayList ListaValores(Int32 inrLista, String idsWhere, Boolean multiselecao, String idsnovocabecalho = "")
        {
            MultiSelecao = multiselecao;

            frmLista = new DevExpress.XtraEditors.XtraForm();
            Int32  iHeight      = 0;
            Int32  iWidth       = 0;
            String isqlConsulta = "";

            try
            {
                tbDadosLista = new DataTable("dadosLista");

                if (Conexao.getInstance().getConnection().State == ConnectionState.Open)
                {
                    Object[] consulta = Utilidades.consultar(String.Format(" select ds_titulo,nr_altura,nr_largura,ds_instrucaosql from listavalores where nr_sequencial = {0}", inrLista));
                    if (consulta != null)
                    {
                        if (Convert.ToInt32(consulta[1]) > 0)
                        {
                            iHeight = Convert.ToInt32(consulta[1]);
                        }
                        if (Convert.ToInt32(consulta[2]) > 0)
                        {
                            iWidth = Convert.ToInt32(consulta[2]);
                        }
                        // se foi passado um novo cabeçalho, usa o que o usuário passou
                        if (idsnovocabecalho.Trim().Length > 0)
                        {
                            frmLista.Text = idsnovocabecalho;
                        }
                        else
                        {
                            frmLista.Text = String.Format("({0}) - {1}", inrLista, Convert.ToString(consulta[0]));
                        }
                        isqlConsulta = Convert.ToString(consulta[3]);
                    }

                    if (!isqlConsulta.Equals(""))
                    {
                        isqlConsulta = isqlConsulta.Replace(":pDsWhere", idsWhere);
                        NpgsqlCommand     cmd     = new NpgsqlCommand(isqlConsulta, Conexao.getInstance().getConnection());
                        NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(cmd);
                        adapter.Fill(tbDadosLista);

                        if (multiselecao)
                        {
                            tbDadosLista.Columns.Add("X", typeof(String)).SetOrdinal(0);
                        }
                    }
                }
                objRetorno               = new ArrayList();
                frmLista.ClientSize      = new Size(iWidth, iHeight + 10);
                frmLista.Font            = new Font("Tahoma", 9, FontStyle.Bold);
                frmLista.WindowState     = FormWindowState.Normal;
                frmLista.FormBorderStyle = FormBorderStyle.FixedSingle;
                frmLista.StartPosition   = FormStartPosition.CenterParent;
                frmLista.KeyPreview      = true;
                frmLista.MaximizeBox     = false;
                frmLista.MinimizeBox     = false;
                frmLista.ShowInTaskbar   = false;
                frmLista.ShowIcon        = false;
                frmLista.TopMost         = true;

                //Tamnho da Tela
                //frmLista.Size = new Size(700, 700);

                ctrlGrid = new DevExpress.XtraGrid.GridControl();
                gridLst  = new DevExpress.XtraGrid.Views.Grid.GridView();

                ctrlGrid.Name       = "ctrlGrid";
                ctrlGrid.MainView   = gridLst;
                gridLst.Name        = "Grid";
                gridLst.GridControl = ctrlGrid;

                ctrlGrid.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { gridLst });
                ctrlGrid.SetBounds(10, 60, iWidth - 20, iHeight - 85);
                ctrlGrid.DataSource     = tbDadosLista;
                ctrlGrid.BindingContext = new BindingContext();
                ctrlGrid.ForceInitialize();
                gridLst.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never;
                gridLst.OptionsView.ColumnAutoWidth     = false;

                List <List <Object> > colunas = Conexao.getInstance().toList(
                    " select nr_coluna,ds_titulocoluna,nm_campoinstrsql,nr_larguracampo,ds_alinhamentocampo " +
                    "   from listavalorescolunas " +
                    "  where nr_sequencial = " + inrLista);
                if (colunas != null)
                {
                    if (multiselecao)
                    {
                        RepositoryItemCheckEdit selectdp = new RepositoryItemCheckEdit();
                        gridLst.Columns[0].ColumnEdit = selectdp;
                        selectdp.NullText             = "N";
                        selectdp.ValueChecked         = "S";
                        selectdp.ValueUnchecked       = "N";
                        selectdp.ValueGrayed          = "N";

                        gridLst.Columns[0].Width = 25;
                        gridLst.Columns[0].AppearanceCell.TextOptions.HAlignment   = DevExpress.Utils.HorzAlignment.Center;
                        gridLst.Columns[0].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                        //gridLst.Columns[0].AppearanceHeader.Font = new Font("Tahoma", 9, FontStyle.Bold);
                        gridLst.Columns[0].Caption = "";
                    }

                    foreach (List <Object> col in colunas)
                    {
                        Int32 nrColuna = multiselecao ? Convert.ToInt32(col.ElementAt(0)) + 1 : Convert.ToInt32(col.ElementAt(0));
                        gridLst.Columns[nrColuna - 1].Width = Convert.ToInt32(col.ElementAt(3));
                        gridLst.Columns[nrColuna - 1].OptionsColumn.AllowEdit = false;
                        gridLst.Columns[nrColuna - 1].OptionsColumn.ReadOnly  = true;
                        gridLst.Columns[nrColuna - 1].Caption = Convert.ToString(col.ElementAt(1));

                        if ((col.ElementAt(4) != null ? col.ElementAt(4).ToString() : "Centralizado") == "Direita")
                        {
                            gridLst.Columns[nrColuna - 1].AppearanceCell.TextOptions.HAlignment   = DevExpress.Utils.HorzAlignment.Far;
                            gridLst.Columns[nrColuna - 1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
                            gridLst.Columns[nrColuna - 1].AppearanceHeader.Font = new Font("Tahoma", 9, FontStyle.Bold);
                        }
                        if ((col.ElementAt(4) != null ? col.ElementAt(4).ToString() : "Centralizado") == "Esquerda")
                        {
                            gridLst.Columns[nrColuna - 1].AppearanceCell.TextOptions.HAlignment   = DevExpress.Utils.HorzAlignment.Near;
                            gridLst.Columns[nrColuna - 1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
                            gridLst.Columns[nrColuna - 1].AppearanceHeader.Font = new Font("Tahoma", 9, FontStyle.Bold);
                        }
                        if ((col.ElementAt(4) != null ? col.ElementAt(4).ToString() : "Centralizado") == "Centralizado")
                        {
                            gridLst.Columns[nrColuna - 1].AppearanceCell.TextOptions.HAlignment   = DevExpress.Utils.HorzAlignment.Center;
                            gridLst.Columns[nrColuna - 1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                            gridLst.Columns[nrColuna - 1].AppearanceHeader.Font = new Font("Tahoma", 9, FontStyle.Bold);
                        }
                    }
                }

                gridLst.GroupPanelText               = "Arraste o Título das Colunas para Agrupar.";
                gridLst.Appearance.GroupPanel.Font   = new Font("Tahoma", 9, FontStyle.Bold);
                gridLst.OptionsSelection.MultiSelect = multiselecao;

                gridLst.GroupPanelText               = "Arraste o Título das Colunas para Agrupar.";
                gridLst.Appearance.GroupPanel.Font   = new Font("Tahoma", 9, FontStyle.Bold);
                gridLst.OptionsSelection.MultiSelect = multiselecao;

                LabelControl lbFiltro    = new LabelControl();
                LabelControl lbInfo      = new LabelControl();
                TextEdit     txtdsFiltro = new TextEdit();

                lbFiltro.Text = "Filtro:";
                lbFiltro.Font = new Font("Tahoma", 9, FontStyle.Bold);
                lbFiltro.SetBounds(7, 23, 50, 15);


                lbInfo.Font = new Font("Tahoma", 9, FontStyle.Bold);
                lbInfo.Text = "Duplo Clique no Registro para Confirmar a Seleção";
                lbInfo.SetBounds(10, iHeight - 15, 350, 13);

                txtdsFiltro.Font = new Font("Tahoma", 9, FontStyle.Regular);
                txtdsFiltro.SetBounds(60, 20, 300, 20);
                txtdsFiltro.Properties.CharacterCasing = CharacterCasing.Upper;
                txtdsFiltro.TabIndex     = 0;
                txtdsFiltro.TextChanged += new EventHandler(dsFiltroChanged);
                txtdsFiltro.KeyDown     += new KeyEventHandler(dsFiltroEnter);

                ctrlGrid.TabIndex = 1;
                ctrlGrid.KeyDown += new KeyEventHandler(dsFiltroEnter);
                if (!multiselecao)
                {
                    ctrlGrid.DoubleClick += new EventHandler(SelecionaRegistro);
                }
                frmLista.KeyDown += new KeyEventHandler(Escape);

                SimpleButton btnConfirmar = new SimpleButton();
                btnConfirmar.SetBounds(iWidth - 110, iHeight - 20, 100, 25);
                btnConfirmar.Text   = "Confirmar";
                btnConfirmar.Font   = new Font(btnConfirmar.Font, FontStyle.Bold);
                btnConfirmar.Font   = new Font("Tahoma", 9, FontStyle.Bold);
                btnConfirmar.Click += new EventHandler(SelecionaRegistro);
                btnConfirmar.Image  = Properties.Resources.Apply_16x16;

                //Desabilita a opção de agrupamento
                gridLst.OptionsView.ShowGroupPanel = false;
                frmLista.Controls.AddRange(new Control[] { ctrlGrid, lbFiltro, txtdsFiltro, lbInfo, btnConfirmar });

                frmLista.ShowDialog();
                frmLista.BringToFront();
            }
            catch (Exception erro)
            {
                Alert.erro("Erro: " + erro.Message);
            }

            return(objRetorno);
        }
示例#2
0
        public static DialogResult InputBox(string title, string promptText, ref string value)
        {
            /*
             * String txt = "";
             * if (InputBox("Envio de e-mail", "Digite o e-mail para envio:", ref txt) == DialogResult.OK) { }
             * if (!txt.Equals(String.Empty)){ }
             */
            XtraForm     form         = new XtraForm();
            LabelControl label        = new LabelControl();
            TextEdit     textBox      = new TextEdit();
            SimpleButton buttonCancel = new SimpleButton();
            SimpleButton buttonOk     = new SimpleButton();

            form.Text    = title;
            label.Text   = promptText;
            textBox.Text = value;

            buttonOk.Text         = "OK";
            buttonOk.DialogResult = DialogResult.OK;
            buttonOk.Image        = Properties.Resources.Apply_16x16;

            buttonCancel.Text         = "Cancelar";
            buttonCancel.DialogResult = DialogResult.Cancel;
            buttonCancel.Image        = Properties.Resources.Cancel_16x16;

            label.SetBounds(7, 10, 372, 20);
            label.Font = new Font(label.Font, FontStyle.Bold);
            label.Font = new Font("Tahoma", 10, FontStyle.Bold);

            textBox.SetBounds(6, 36, 380, 50);
            textBox.Font = new Font("Tahoma", 10);

            buttonOk.SetBounds(220, 65, 75, 23);
            buttonOk.Font = new Font(buttonOk.Font, FontStyle.Bold);
            buttonOk.Font = new Font("Tahoma", 10, FontStyle.Bold);

            buttonCancel.SetBounds(300, 65, 85, 23);
            buttonCancel.Font = new Font(buttonCancel.Font, FontStyle.Bold);
            buttonCancel.Font = new Font("Tahoma", 10, FontStyle.Bold);

            label.AutoSize      = true;
            textBox.Anchor      = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 100);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.ShowIcon        = false;
            form.ShowInTaskbar   = false;
            form.AcceptButton    = buttonOk;
            form.CancelButton    = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();

            value = textBox.Text;
            return(dialogResult);
        }