public void BindCompanyList(DropDownList ddlCompanyList, HtmlControl dvAdministrator) { FuneralServiceReference.FuneralServicesClient privateClient = new FuneralServiceReference.FuneralServicesClient(); dvAdministrator.Visible = IsAdministrator; if (this.IsAdministrator) { List <ApplicationSettingsModel> model = privateClient.GetAllApplicationList(ParlourId, 1, 0).ToList(); if (model != null) { ddlCompanyList.Visible = true; ddlCompanyList.DataTextField = "ApplicationName"; ddlCompanyList.DataValueField = "ParlourId"; ddlCompanyList.DataSource = model; ddlCompanyList.DataBind(); //ddlCompanyList.Items.Insert(0, new ListItem("Select", "0")); ddlCompanyList.SelectedValue = ParlourId.ToString(); } else { ddlCompanyList.Items.Insert(0, new ListItem(ApplicationName, ParlourId.ToString())); ddlCompanyList.SelectedValue = ParlourId.ToString(); } } else { ddlCompanyList.Items.Insert(0, new ListItem(ApplicationName, ParlourId.ToString())); ddlCompanyList.SelectedValue = ParlourId.ToString(); } }
protected void ExportClickEvent(object sender, EventArgs e) { try { // ReportViewer rpw = new ReportViewer(); rpw.ProcessingMode = ProcessingMode.Remote; IReportServerCredentials irsc = new MyReportServerCredentials(); rpw.ServerReport.ReportServerCredentials = irsc; rpw.ProcessingMode = ProcessingMode.Remote; rpw.ServerReport.ReportServerUrl = new Uri(_siteConfig.SSRSUrl); //rpw.ServerReport.ReportPath = "/Unplugg IT Solution BI Reporting/Unplugg IT Busy Days //UIS All Members Report"; rpw.ServerReport.ReportPath = "/Mosys Reports/" + hfAdminReport.Value; // ReportParameterCollection reportParameters = new ReportParameterCollection(); if (!string.IsNullOrEmpty(txtDateFrom.Text)) { reportParameters.Add(new ReportParameter("StartDateFrom", txtDateFrom.Text)); } if (!string.IsNullOrEmpty(txtDateTo.Text)) { reportParameters.Add(new ReportParameter("StartDateTo", txtDateTo.Text)); } //if (!string.IsNullOrEmpty(txtDateFrom.Text)) // reportParameters.Add(new ReportParameter("DebitDateFrom", txtDebitDateFrom.Text)); //if (!string.IsNullOrEmpty(txtDateTo.Text)) // reportParameters.Add(new ReportParameter("DebitDateTo", txtDebitDateTo.Text)); if (!string.IsNullOrEmpty(ddlAgent.SelectedItem.Text)) { reportParameters.Add(new ReportParameter("Agent", ddlAgent.SelectedItem.Text)); } if (!string.IsNullOrEmpty(ddlPolicyStatus.SelectedItem.Text)) { reportParameters.Add(new ReportParameter("PolicyStatus", ddlPolicyStatus.SelectedItem.Text)); } reportParameters.Add(new ReportParameter("Parlourid", ParlourId.ToString())); rpw.ServerReport.SetParameters(reportParameters); // Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; string filename; // string ExportTypeName = rptExportType.SelectedItem.Text; string ExportTypeExtensions; if (ExportTypeName == "PDF") { ExportTypeExtensions = "pdf"; } else if (ExportTypeName == "Word") { ExportTypeExtensions = "docx"; } else { ExportTypeExtensions = "xls"; } // byte[] bytes = rpw.ServerReport.Render(ExportTypeName, null, out mimeType, out encoding, out extension, out streamids, out warnings); filename = string.Format("{0}.{1}", hfAdminReport.Value, ExportTypeExtensions); //MailSend if (!string.IsNullOrEmpty(txtcemail.Text)) { MemoryStream s = new MemoryStream(bytes); s.Seek(0, SeekOrigin.Begin); Attachment a = new Attachment(s, filename); MailMessage message = new MailMessage(ConfigurationManager.AppSettings["ReportEmailSenderId"].ToString().Trim(), txtcemail.Text.Trim(), hfAdminReport.Value, ""); message.Attachments.Add(a); SmtpClient client = new SmtpClient(); client.Send(message); lblMessage.ForeColor = System.Drawing.Color.Green; lblMessage.Text = "Email Sent Successfully."; } // else { Response.ClearHeaders(); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=" + filename); Response.ContentType = mimeType; Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } } catch (Exception ex) { ShowMessage(ref lblMessage, MessageType.Danger, ex.Message); } }