Example #1
0
        public bool FileSave()
        {
            string           rdl     = GetRdlText();
            string           sql     = this.rdlDesigner.ReportDocument.GetElementsByTagName("CommandText")[0].InnerXml;
            List <SqlColumn> columns = DesignerUtility.GetSqlColumns(sql);

            OpenPOS.Model.Reports.IRelatorio current = rdlDesigner.CurrentReport;

            if (current == null)
            {
                current = new OpenPOS.Data.Reports.Relatorio();
            }

            SaveDialogResult sdresult = SaveDialog.Show(current.Nome, current.Grupo == null ? (OpenPOS.GUID) "" : current.Grupo.GUID, columns, current);

            if (sdresult.DialogResult == DialogResult.OK)
            {
                current.Nome     = sdresult.Title;
                current.Grupo    = sdresult.Group;
                current.Filtros  = sdresult.Filtros;
                current.Script   = rdl;
                current.Template = sdresult.Template;
                if (_flagFileSaveAs)
                {
                    current.New = true;
                }

                current.Save();
                Editor.CurrentReport = current;
                return(true);
            }
            return(false);
        }
        private void bCancel_Click(object sender, EventArgs e)
        {
            Result = new SaveDialogResult
            {
                DialogResult = DialogResult.Cancel,
                Success      = false
            };

            DialogResult = DialogResult.Cancel;
            Hide();
        }
        private void frmDialogSave_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                Result = new SaveDialogResult
                {
                    DialogResult = DialogResult.Cancel,
                    Success      = false
                };

                DialogResult = DialogResult.Cancel;
            }
        }
        public static SaveDialogResult Show(string title, OpenPOS.GUID group, List <SqlColumn> colunas, IRelatorio relatorio)
        {
            frmDialogSave save         = new frmDialogSave(colunas, relatorio);
            RdlDesigner   _rdlDesigner = save.Parent as RdlDesigner;

            save.txtTitle.Text = title;
            save.sfGroup.SetValue(group.ToString());
            save.ShowDialog();
            SaveDialogResult result = save.Result;

            save.Close();
            save.Dispose();
            return(result);
        }
        private void bOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.None;
            IList <IFiltro> filtros = new List <IFiltro>();

            if (String.IsNullOrEmpty(txtTitle.Text))
            {
                MessageBox.Show("The \"Title\" field is required");
                return;
            }

            if (!OpenPOS.GUID.IsValid(sfGroup.SelectedItem.GUID))
            {
                MessageBox.Show("The \"Group\" field is required");
                return;
            }

            foreach (DataGridViewRow row in grdFiltros.Rows
                     .Cast <DataGridViewRow>()
                     .Where(w => !w.IsNewRow))
            {
                if (row.Cells[this.dgvApelido.Index].Value == null)
                {
                    OpenPOS.MessageBox.Show("Obrigatório informar o \"Apelido\" na linha selecionada.", MessageBoxIcon.Exclamation);
                    row.Selected = true;
                    return;
                }
                if (row.Cells[this.dgvNomeReal.Index].Value == null)
                {
                    OpenPOS.MessageBox.Show("Obrigatório informar o \"NomeReal\" na linha selecionada.", MessageBoxIcon.Exclamation);
                    row.Selected = true;
                    return;
                }
                if (row.Cells[this.dgvTipo.Index].Value == null)
                {
                    OpenPOS.MessageBox.Show("Obrigatório informar o \"Tipo\" na linha selecionada.", MessageBoxIcon.Exclamation);
                    row.Selected = true;
                    return;
                }

                Filtro filtro = new Filtro();
                if (row.Cells[this.dgvApelido.Index].Value != null)
                {
                    filtro.Apelido = row.Cells[this.dgvApelido.Index].Value.ToString();
                }
                if (row.Cells[this.dgvNomeReal.Index].Value != null)
                {
                    filtro.NomeReal = row.Cells[this.dgvNomeReal.Index].Value.ToString();
                }
                if (row.Cells[this.dgvClassificacao.Index].Value != null)
                {
                    filtro.Classificacao = OpenPOS.Convert.ToEnum <OrderByClassification>(row.Cells[this.dgvClassificacao.Index].Value.ToString());
                }
                if (row.Cells[this.dgvTipo.Index].Value != null)
                {
                    filtro.Tipo = OpenPOS.Convert.ToEnum <GenericDbType>(row.Cells[this.dgvTipo.Index].Value.ToString());
                }
                if (row.Cells[this.dgvObrigatorio.Index].Value != null)
                {
                    filtro.Obrigatorio = Convert.ToBoolean(row.Cells[this.dgvObrigatorio.Index].Value);
                }
                if (row.Cells[this.dgvPadrao.Index].Value != null)
                {
                    filtro.Padrao = Convert.ToBoolean(row.Cells[this.dgvPadrao.Index].Value.ToString());
                }
                if (row.Cells[this.dgvComparacao.Index].Value != null)
                {
                    filtro.Comparacao = OpenPOS.Convert.ToEnum <ComparisonType>(row.Cells[this.dgvComparacao.Index].Value.ToString());
                }
                if (row.Cells[this.dgvVlr1.Index].Value != null)
                {
                    filtro.Valor = row.Cells[this.dgvVlr1.Index].Value.ToString();
                }
                if (row.Cells[this.dgvVlr2.Index].Value != null)
                {
                    filtro.Valor2 = row.Cells[this.dgvVlr2.Index].Value.ToString();
                }
                filtros.Add(filtro);
            }

            Result = new SaveDialogResult
            {
                Success      = true,
                DialogResult = DialogResult.OK,
                Group        = new Grupo
                {
                    GUID = sfGroup.SelectedItem.GUID,
                    Nome = sfGroup.SelectedItem.Descricao
                },
                Filtros  = filtros,
                Template = chkTemplate.Checked,
                Title    = txtTitle.Text
            };

            DialogResult = DialogResult.OK;

            Hide();
        }