Example #1
0
        private void ExportarRelatorio()
        {
            try
            {
                int    iIDCampanha = Convert.ToInt32(comboCampanha.SelectedValue);
                int    iIDMailing  = Convert.ToInt32(comboMailing.SelectedValue);
                string sIDStatus   = "";
                if (chlStatus.Items.Count != chlStatus.CheckedItems.Count)
                {
                    foreach (object itemChecked in chlStatus.CheckedItems)
                    {
                        if (sIDStatus != "")
                        {
                            sIDStatus += ", ";
                        }

                        sIDStatus += itemChecked.ToString().Substring(0, 1) != "-" ? itemChecked.ToString().Substring(0, itemChecked.ToString().IndexOf("-") - 1) : itemChecked.ToString().Substring(0, itemChecked.ToString().IndexOf("-", 1) - 1);
                    }
                }

                relatorioCTL CRelatorio = new relatorioCTL();
                DataTable    dataTable  = CRelatorio.RetornarExportacaoMailing(iIDCampanha, iIDMailing, sIDStatus);

                string sEnderecoArquivo = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "Tabulare - ExportacaoMailing.xls";
                dataTable.TableName = "Tabulare";
                dataTable.WriteXml(sEnderecoArquivo, System.Data.XmlWriteMode.IgnoreSchema);

                MessageBox.Show("Dados exportados com sucesso!\n\nO arquivo encontra-se na Área de Trabalho.", "Tabulare");
            }
            catch (Exception ex)
            {
                PontoBr.Utilidades.Diversos.ExibirAlertaWindowsForm(ex.Message, "Tabulare Software");
            }
        }
Example #2
0
        private void GerarRelatorio()
        {
            try
            {
                int    iIDCampanha = Convert.ToInt32(comboCampanha.SelectedValue);
                int    iIDMailing  = Convert.ToInt32(comboMailing.SelectedValue);
                string sIDStatus   = "";
                if (chlStatus.Items.Count != chlStatus.CheckedItems.Count)
                {
                    foreach (object itemChecked in chlStatus.CheckedItems)
                    {
                        if (sIDStatus != "")
                        {
                            sIDStatus += ", ";
                        }

                        sIDStatus += itemChecked.ToString().Substring(0, 1) != "-" ? itemChecked.ToString().Substring(0, itemChecked.ToString().IndexOf("-") - 1) : itemChecked.ToString().Substring(0, itemChecked.ToString().IndexOf("-", 1) - 1);
                    }
                }

                relatorioCTL CRelatorio = new relatorioCTL();
                DataTable    dataTable  = CRelatorio.RetornarExportacaoMailing(iIDCampanha, iIDMailing, sIDStatus);

                dgDados.DataSource = dataTable;
            }
            catch (Exception ex)
            {
                PontoBr.Utilidades.Diversos.ExibirAlertaWindowsForm(ex.Message, "Tabulare Software");
            }
        }
    private void ExportarRelatorio()
    {
        try
        {
            int    iIDCampanha = Convert.ToInt32(dropCampanha.SelectedValue);
            int    iIDMailing  = Convert.ToInt32(dropMailing.SelectedValue);
            string sIDStatus   = "";

            int iSelecionados = 0;
            foreach (ListItem listItem in chkStatus.Items)
            {
                if (listItem.Selected)
                {
                    sIDStatus += sIDStatus != "" ? ", " + listItem.Value : listItem.Value;
                    iSelecionados++;
                }
            }
            if (iSelecionados == chkStatus.Items.Count)
            {
                sIDStatus = "";
            }

            relatorioCTL CRelatorio = new relatorioCTL();
            DataTable    dataTable  = CRelatorio.RetornarExportacaoMailing(iIDCampanha, iIDMailing, sIDStatus);

            dgDados.DataSource = dataTable;
            dgDados.DataBind();

            if (dataTable.Rows.Count > 0)
            {
                lblMensagem.Text = "";

                Response.Clear();
                string sNomeArquivo = "Tabulare_ExportacaoMailing.xls";
                Response.AddHeader("content-disposition", "attachment;filename=" + sNomeArquivo + "");
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.ContentType = "application/vnd.xls";
                System.IO.StringWriter       sWr = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter hWr = new HtmlTextWriter(sWr);
                dgDados.RenderControl(hWr);

                Response.Write(sWr.ToString());
                Response.End();
            }
            else
            {
                lblMensagem.Text = "Não há prospects neste [Mailing].";
            }
        }
        catch (Exception ex)
        {
            PontoBr.Utilidades.Diversos.ExibirAlertaScriptManager(ex.Message, this.Page);
        }
    }