private void GeneratePDFReport() { string Grade = string.Empty; ; string Subject = string.Empty; ; string Course = string.Empty; ; string StudentId = string.Empty; ; if (Request.QueryString["Grade"] != null) { Grade = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Grade"].ToString()); } if (Request.QueryString["Subject"] != null) { Subject = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Subject"].ToString()); } if (Request.QueryString["Course"] != null) { Course = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Course"].ToString()); } if (Request.QueryString["StudentId"] != null) { StudentId = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["StudentId"]); } var DParms = DistrictParms.LoadDistrictParms(); string ClientID = DParms.ClientID; string Year = DParms.Year; Microsoft.Reporting.WebForms.ReportViewer rptViewer = new Microsoft.Reporting.WebForms.ReportViewer(); rptViewer.ProcessingMode = ProcessingMode.Remote; rptViewer.ServerReport.ReportServerCredentials = new CustomReportCredentials(reportUsername.Value, reportPassword.Value, reportDomain.Value); rptViewer.ServerReport.ReportServerUrl = new Uri(reportServerUrl.Value); rptViewer.ServerReport.ReportPath = reportPath.Value; rptViewer.ShowParameterPrompts = false; var reportParameterCollection = new ReportParameterCollection(); reportParameterCollection.Add(new ReportParameter("ClientID", ClientID)); reportParameterCollection.Add(new ReportParameter("Year", Year)); reportParameterCollection.Add(new ReportParameter("Grade", Grade)); reportParameterCollection.Add(new ReportParameter("Subject", Subject)); reportParameterCollection.Add(new ReportParameter("Course", Course)); reportParameterCollection.Add(new ReportParameter("StudentTGID", StudentId)); rptViewer.ServerReport.SetParameters(reportParameterCollection); rptViewer.ServerReport.Refresh(); Warning[] warnings; string[] streamids; string mimeType, encoding, extension; byte[] bytes = rptViewer.ServerReport.Render("PDF", string.Empty, out mimeType, out encoding, out extension, out streamids, out warnings); using (MemoryStream memoryStream = new MemoryStream(bytes)) { Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "inline; filename=AssessmentReportCard.pdf"); Response.AddHeader("content-length", bytes.Length.ToString()); Response.BinaryWrite(memoryStream.ToArray()); Response.Flush(); Response.End(); } }
protected void Report_Execution(object sender, DirectEventArgs e) { string formatoSalida = ""; try { ReporteLogic reporteLogic = new ReporteLogic(); List<reporte_hojas_de_liquidacion> ReporteDetalleDeHojasDeLiquidacionLst = reporteLogic.GetDetalleHojasDeLiquidacion (this.f_SOCIOS_ID.Text, string.IsNullOrEmpty(this.f_CLASIFICACIONES_CAFE_ID.Text) ? 0 : Convert.ToInt32(this.f_CLASIFICACIONES_CAFE_ID.Text), this.f_FECHA.Text, this.f_DATE_FROM.SelectedDate, this.f_DATE_TO.SelectedDate); ReportDataSource datasourceDetalleDeHojasDeLiquidacion = new ReportDataSource("HojaDeLiquidacionDataSet", ReporteDetalleDeHojasDeLiquidacionLst); ReportParameterCollection reportParamCollection = new ReportParameterCollection(); reportParamCollection.Add(new ReportParameter("parGroupBySocios", this.g_SOCIOS_ID.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByClasificacionCafe", this.g_CLASIFICACIONES_CAFE_ID.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByFecha", this.g_FECHA.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parMostrarQuintales", this.p_QUINTALES.Checked.ToString())); formatoSalida = this.f_SALIDA_FORMATO.Text; string rdlPath = "~/resources/rdlcs/ReporteHojasDeLiquidacion.rdlc"; this.CreateFileOutput("ReporteDeHojasDeLiquidacion", formatoSalida, rdlPath, datasourceDetalleDeHojasDeLiquidacion, reportParamCollection); } catch (Exception ex) { log.Fatal(string.Format("Error fatal al generar reporte. Formato de salida: {0}", formatoSalida), ex); throw; } }
protected void executeReport_click(object sender, EventArgs e) { if (reportSelector.SelectedIndex == 9) executeReportInAppDomain_click(sender, e); else { LocalReport rpt = new LocalReport(); rpt.EnableExternalImages = true; rpt.ReportPath = String.Concat(Path.GetDirectoryName(Request.PhysicalPath), "\\Reports\\", reportSelector.SelectedValue); string orientation = (rpt.GetDefaultPageSettings().IsLandscape) ? "landscape" : "portrait"; StringReader formattedReport = Business.reportHelper.FormatReportForTerritory(rpt.ReportPath, orientation, cultureSelector.SelectedValue); rpt.LoadReportDefinition(formattedReport); // Add Data Source rpt.DataSources.Add(new ReportDataSource("InvoiceDataTable", dt)); // Internationlisation: Add uiCulture and Translation Labels if (reportSelector.SelectedIndex >= 3) { Dictionary<string, string> reportLabels = Reports.reportTranslation.translateInvoice(cultureSelector.SelectedValue); ReportParameterCollection reportParams = new ReportParameterCollection(); reportParams.Add(new ReportParameter("uiCulture", cultureSelector.SelectedValue)); foreach (string key in reportLabels.Keys) reportParams.Add(new ReportParameter(key, reportLabels[key])); rpt.SetParameters(reportParams); } // Render To Browser renderPDFToBrowser(rpt.Render("PDF", Business.reportHelper.GetDeviceInfoFromReport(rpt, cultureSelector.SelectedValue, "PDF"))); } }
public RecipePrinter(DataGridView dataTable, string recipeName, string recipeProcedure, string imageLocation) { try { _recipeIngredients = GetTableData(dataTable); if (string.IsNullOrEmpty(imageLocation)) { imageLocation = Directory.GetCurrentDirectory() + @"//NoImage.bmp"; Resources.NoImage.Save(imageLocation, ImageFormat.Bmp); } var parameters = new ReportParameterCollection { new ReportParameter("RecipeTitle", recipeName), new ReportParameter("RecipeText", recipeProcedure), new ReportParameter("Path", imageLocation) }; InitializeComponent(); reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", _recipeIngredients)); reportViewer1.LocalReport.EnableExternalImages = true; reportViewer1.LocalReport.SetParameters(parameters); } catch (Exception e) { throw e.GetBaseException(); } }
protected void Export_PDFBtn_Click(object sender, DirectEventArgs e) { string formatoSalida = ""; try { COCASJOL.LOGIC.Aportaciones.AportacionLogic reporteLogic = new COCASJOL.LOGIC.Aportaciones.AportacionLogic(); List<COCASJOL.DATAACCESS.reporte_total_aportaciones_por_socio> ReporteAportacionesDeSociosLst = reporteLogic.GetAportaciones (this.f_SOCIOS_ID.Text, this.f_SOCIOS_NOMBRE_COMPLETO.Text, string.IsNullOrEmpty(this.f_APORTACIONES_SALDO_TOTAL.Text) ? -1 : Convert.ToInt32(this.f_APORTACIONES_SALDO_TOTAL.Text), "", default(DateTime)); ReportDataSource datasourceAportacionesSocios = new ReportDataSource("ResumenAportacionesPorSocioDataSet", ReporteAportacionesDeSociosLst); ReportParameterCollection reportParamCollection = new ReportParameterCollection(); formatoSalida = "PDF"; string rdlPath = "~/resources/rdlcs/ReportResumenAportacionesPorSocio.rdlc"; this.CreateFileOutput("ReporteResumenAportacionesDeSocios", formatoSalida, rdlPath, datasourceAportacionesSocios, reportParamCollection); } catch (Exception ex) { log.Fatal(string.Format("Error fatal al generar reporte. Formato de salida: {0}", formatoSalida), ex); throw; } }
protected void Export_PDFBtn_Click(object sender, DirectEventArgs e) { string formatoSalida = ""; try { COCASJOL.LOGIC.Inventario.InventarioDeCafeLogic reporteLogic = new COCASJOL.LOGIC.Inventario.InventarioDeCafeLogic(); List<COCASJOL.DATAACCESS.reporte_total_inventario_de_cafe_por_socio> ReporteInventarioDeCafeDeSociosLst = reporteLogic.GetInventarioDeCafeDeSocios (this.f_SOCIOS_ID.Text, this.f_SOCIOS_NOMBRE_COMPLETO.Text, string.IsNullOrEmpty(this.f_CLASIFICACIONES_CAFE_ID.Text) ? 0 : Convert.ToInt32(this.f_CLASIFICACIONES_CAFE_ID.Text), string.IsNullOrEmpty(this.f_INVENTARIO_ENTRADAS_CANTIDAD.Text) ? -1 : Convert.ToInt32(this.f_INVENTARIO_ENTRADAS_CANTIDAD.Text), string.IsNullOrEmpty(this.f_INVENTARIO_SALIDAS_SALDO.Text) ? -1 : Convert.ToInt32(this.f_INVENTARIO_SALIDAS_SALDO.Text), "", default(DateTime)); ReportDataSource datasourceInventarioCafeSocios = new ReportDataSource("ResumenDeInventarioDeCafeDeSociosDataSet", ReporteInventarioDeCafeDeSociosLst); ReportParameterCollection reportParamCollection = new ReportParameterCollection(); reportParamCollection.Add(new ReportParameter("parMostrarQuintales", this.p_QUINTALES.Checked.ToString())); formatoSalida = "PDF"; string rdlPath = "~/resources/rdlcs/ReportResumenInventarioDeCafeDeSocios.rdlc"; this.CreateFileOutput("ReporteResumenInventarioDeCafeDeSocios", formatoSalida, rdlPath, datasourceInventarioCafeSocios, reportParamCollection); } catch (Exception ex) { log.Fatal(string.Format("Error fatal al generar reporte. Formato de salida: {0}", formatoSalida), ex); throw; } }
protected void Report_Execution(object sender, DirectEventArgs e) { string formatoSalida = ""; try { ReporteLogic reporteLogic = new ReporteLogic(); int prestamos_id = string.IsNullOrEmpty(this.f_PRESTAMOS_ID.Text) ? 0 : Convert.ToInt32(this.f_PRESTAMOS_ID.Text); List<solicitud_prestamo> ReportePrestamosXSociosLst = reporteLogic.GetPrestamosXSocio (this.f_SOCIOS_ID.Text, prestamos_id); ReportDataSource datasourceMovimientoInventarioCafeSocios = new ReportDataSource("PrestamosXSocioDataSet", ReportePrestamosXSociosLst); ReportParameterCollection reportParamCollection = new ReportParameterCollection(); reportParamCollection.Add(new ReportParameter("parGroupBySocios", this.g_SOCIOS_ID.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByPrestamo", this.g_PRESTAMOS_ID.Checked.ToString())); formatoSalida = this.f_SALIDA_FORMATO.Text; string rdlPath = "~/resources/rdlcs/ReportePrestamosPorSocios.rdlc"; this.CreateFileOutput("ReportePrestamosPorSocios", formatoSalida, rdlPath, datasourceMovimientoInventarioCafeSocios, reportParamCollection); } catch (Exception ex) { log.Fatal(string.Format("Error fatal al generar reporte. Formato de salida: {0}", formatoSalida), ex); throw; } }
private void token_Load(object sender, EventArgs e) { header(); string name = "notfound"; string date = "notfound"; string doctor = "notfound"; string fees = "notfound"; string address = "notfound"; string age = "notfound"; string sex = "notfound"; string weight = "notfound"; string hospital_id = ""; string card_id = ""; try { db.sql.Close(); db.sql.Open(); SqlCommand cmd = new SqlCommand("select * from appointment where reg_no='" + reg_no + "'", db.sql); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { name = read[1].ToString(); date = read[6].ToString(); doctor = read[7].ToString(); fees = read[8].ToString(); address = read[2].ToString(); age = read[3].ToString(); sex = read[4].ToString(); weight = read[9].ToString(); hospital_id = read[14].ToString(); card_id = read[11].ToString(); } } catch { } ReportParameterCollection r = new ReportParameterCollection(); r.Add(new ReportParameter("reg_no", reg_no)); r.Add(new ReportParameter("name", name)); r.Add(new ReportParameter("doctor", doctor)); r.Add(new ReportParameter("date", date)); r.Add(new ReportParameter("fees", fees)); r.Add(new ReportParameter("address", address)); r.Add(new ReportParameter("age", age)); r.Add(new ReportParameter("sex", sex)); r.Add(new ReportParameter("weight", weight)); r.Add(new ReportParameter("hospital_id", hospital_id)); r.Add(new ReportParameter("card_id", card_id)); this.reportViewer1.LocalReport.SetParameters(r); db.sql.Close(); this.reportViewer1.RefreshReport(); }
private void fHoaDonXuat_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'DataSetHoaDonXuat.LayHoaDonXuat' table. You can move, or remove it, as needed. ReportParameterCollection reportParam = new ReportParameterCollection(); reportParam.Add(new ReportParameter("NgayLap", DateTime.Now.ToShortDateString())); reportParam.Add(new ReportParameter("MaPX", MaPX.ToString())); this.LayHoaDonXuatTableAdapter.Fill(this.DataSetHoaDonXuat.LayHoaDonXuat, MaPX); this.rpXuatHang.LocalReport.SetParameters(reportParam); this.rpXuatHang.RefreshReport(); }
void header() { try { string d = dateTimePicker1.Text; string d2 = dateTimePicker2.Text; string name = ""; string address = ""; string phone = ""; string mobile = ""; string establish = ""; db.sql.Close(); db.sql.Open(); SqlCommand cmd = new SqlCommand("select * from print_head", db.sql); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { name = read[1].ToString(); address = read[2].ToString(); phone = read[3].ToString(); mobile = read[4].ToString(); establish = read[5].ToString(); MemoryStream ms = new MemoryStream((byte[])read[6]); logo = Image.FromStream(ms); try { // Convert Image to byte[] byte[] imageBytes = ms.ToArray(); // Convert byte[] to Base64 String base64String = Convert.ToBase64String(imageBytes); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } ReportParameterCollection r = new ReportParameterCollection(); r.Add(new ReportParameter("name", name.ToString())); r.Add(new ReportParameter("address", address.ToString())); r.Add(new ReportParameter("phone", phone.ToString())); r.Add(new ReportParameter("date1", d.ToString())); r.Add(new ReportParameter("date2", d2.ToString())); r.Add(new ReportParameter("logo", base64String.ToString())); this.reportViewer1.LocalReport.SetParameters(r); db.sql.Close(); } catch { } }
public rptOrdercs() { // // Required for telerik Reporting designer support // InitializeComponent(); ReportParameterCollection lparams = this.ReportParameters; lparams[0].Value = Environment.MachineName; }
private void hd_banhang_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'tt.HD_banhang' table. You can move, or remove it, as needed. this.HD_banhangTableAdapter.Fill(this.tt.HD_banhang, int.Parse(mahd), makh); ReportParameterCollection reportParameter = new ReportParameterCollection(); reportParameter.Add(new ReportParameter("mahd", mahd.ToString())); reportParameter.Add(new ReportParameter("tienkm", tienkm.ToString())); reportParameter.Add(new ReportParameter("tongtien", tongtien.ToString())); this.reportViewer1.LocalReport.SetParameters(reportParameter); this.reportViewer1.RefreshReport(); }
public rptDeliveryByDate(DateTime pST, DateTime pET) { // // Required for telerik Reporting designer support // InitializeComponent(); ReportParameterCollection lparams = this.ReportParameters; lparams[0].Value = Environment.MachineName; lparams[1].Value = pST; lparams[2].Value = pET; }
private void btnFill_Click(object sender, EventArgs e) { ReportParameterCollection reportParameters = new ReportParameterCollection(); reportParameters.Add(new ReportParameter("parameterCompanyName", " ")); reportParameters.Add(new ReportParameter("parameterContactName", " ")); reportParameters.Add(new ReportParameter("parameterAddress", " ")); reportParameters.Add(new ReportParameter("parameterCity", " ")); reportViewer1.LocalReport.SetParameters(reportParameters); Order_DetailsTableAdapter.Fill(NorthwindDataSet.Order_Details); Order_Details_fill_name(); }
public ActionResult PrintWOFactur(string random, string woId) { string msg = string.Empty; bool success = false; bool allowPrint = true; try { //get wo by wo id TWO wo = this._woTasks.One(woId); //check if user have print WO, if not, allow print for role CS if (User.IsInRole("CS")) { allowPrint = !_woLogTasks.HaveBeenPrint(wo, User.Identity.Name); } if (allowPrint) { ReportParameterCollection paramCol = null; ReportDataSource[] repCol = new ReportDataSource[1]; //get data source repCol[0] = GetWOById(wo); //save log SaveLog(wo, EnumWOLog.Print); Session["ReportData"] = repCol; Session["ReportParams"] = paramCol; success = true; msg = "Print WO success"; } else { success = false; msg = "Anda sudah pernah mencetak WO"; } } catch (Exception ex) { success = false; msg = ex.GetBaseException().Message; } var e = new { Success = success, Message = msg, UrlReport = string.Format("{0}", EnumReports.RptPrintWOFactur.ToString()) }; return(Json(e, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 生成团队报告 /// </summary> /// <param name="modelPath">报告模板</param> /// <param name="tigerPath">生成地址</param> /// <param name="formId">问卷编号</param> /// <param name="suffix">报告格式</param> /// <returns></returns> public Result CreateTeamReport(string modelPath, string tigerPath, long formId, string suffix) { return(RunFun(logPath => { tigerPath = ToolFile.GetAbsolutelyPath(tigerPath); modelPath = base.ModelPath + modelPath; string sqlFilter = $"SELECT * FROM AskForm_FormFilter ff WHERE ff.FormID = {formId} AND ff.Name LIKE '%FieldFilter%' AND ff.IsDeleted = 0"; DataTable dtFilter = DbContent.GetTable(sqlFilter); // 循环过滤条件 foreach (DataRow filter in dtFilter.Rows) { ReportParameterCollection col = new ReportParameterCollection { new ReportParameter("CompanyID", filter["CompanyID"] + ""), new ReportParameter("FormApplicationID", filter["FormApplicationID"] + ""), new ReportParameter("FormID", filter["FormID"] + ""), new ReportParameter("FormFilterID", filter["FormFilterID"] + ""), new ReportParameter("MinValue", "1") }; col = ToolReport.BindPara(modelPath, col); // 获取过滤字段 string sqlField = $"SELECT f.FieldID,f.Title,fff.Content FROM AskForm_FormFilterField fff INNER JOIN AskForm_Field f ON f.FieldID = fff.FieldID WHERE FormFilterID = {filter["FormFilterID"]} AND fff.IsDeleted = 0"; DataTable dtField = DbContent.GetTable(sqlField); // 循环字段 foreach (DataRow field in dtField.Rows) { string sqlContent = $"SELECT distinct [Value] FROM AskForm_EntryText et WHERE et.FieldID = {field["FieldID"]} AND et.IsDeleted = 0"; DataTable dtContent = DbContent.GetTable(sqlContent); // 循环内容 foreach (DataRow content in dtContent.Rows) { // 修改内容 string sqlUpFilterField = $"UPDATE AskForm_FormFilterField SET Content='{content["Value"]}' WHERE FormFilterID = {filter["FormFilterID"]} AND FieldID ={field["FieldID"]} "; WriteLog(logPath, "修改【" + field["Title"] + "】为【" + content["Value"] + "】," + DbContent.ExecuteNonQuery(sqlUpFilterField)); ToolReport.GenerateLocalReport(modelPath, tigerPath, field["Title"] + "_" + content["Value"] + "." + suffix, col, false); } } } return Res; })); }
private void hd_nhaphang_Load(object sender, EventArgs e) { this.cT_NHAP_SP_DK_LUUKHOTableAdapter.Fill_DK(this.nghiepVu.CT_NHAP_SP_DK_LUUKHO, manhap); ReportParameterCollection reportParameter = new ReportParameterCollection(); reportParameter.Add(new ReportParameter("mahd", mahd.ToString())); reportParameter.Add(new ReportParameter("manhap", manhap.ToString())); reportParameter.Add(new ReportParameter("tongtien", tongtien.ToString())); reportParameter.Add(new ReportParameter("ngayin", ngayin.ToString())); reportParameter.Add(new ReportParameter("tennv", ngayin.ToString())); this.reportViewer1.LocalReport.SetParameters(reportParameter); this.reportViewer1.RefreshReport(); }
private void hd_tragop_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'tt.TraGop1' table. You can move, or remove it, as needed. this.TraGop1TableAdapter.Fill_dk(this.tt.TraGop1, matragop); this.ct_mua_sp_lkTableAdapter.Fill(this.nghiepVu.ct_mua_sp_lk, ((int)(System.Convert.ChangeType(mahd, typeof(int))))); ReportParameterCollection reportParameter = new ReportParameterCollection(); reportParameter.Add(new ReportParameter("mahd", mahd.ToString())); reportParameter.Add(new ReportParameter("matragop", matragop.ToString())); reportParameter.Add(new ReportParameter("ngay", ngay.ToString())); this.reportViewer1.LocalReport.SetParameters(reportParameter); this.reportViewer1.RefreshReport(); }
private void frm_Izvjestaj_Load(object sender, EventArgs e) { ReportParameterCollection rpc = new ReportParameterCollection(); rpc.Add(new ReportParameter("Ime", rezervacija.Korisnik.Ime)); rpc.Add(new ReportParameter("Prezime", rezervacija.Korisnik.Prezime)); rpc.Add(new ReportParameter("DatumOd", rezervacija.DatumOd)); rpc.Add(new ReportParameter("DatumDo", rezervacija.DatumDo)); rpc.Add(new ReportParameter("Cijena", rezervacija.Cijena.ToString())); rpc.Add(new ReportParameter("TrenutniDatum", DateTime.Now.ToString())); reportViewer1.LocalReport.SetParameters(rpc); this.reportViewer1.RefreshReport(); }
/// <summary> /// Funkcija koja izvjestaju salje parametre /// </summary> private void NapuniIzvjestaj() { ReportParameterCollection parametri = new ReportParameterCollection(); parametri.Add(new ReportParameter("ImeKorisnika", Ime)); parametri.Add(new ReportParameter("PrezimeKorisnika", Prezime)); parametri.Add(new ReportParameter("PlacaSat", PlacaPoSatu.ToString())); parametri.Add(new ReportParameter("RadniSat", RadniSati.ToString())); parametri.Add(new ReportParameter("RadniDan", RadniDani.ToString())); parametri.Add(new ReportParameter("Ukupno", Ukupno.ToString())); parametri.Add(new ReportParameter("Datum", Datum.ToString())); this.rpvPreglednik.LocalReport.SetParameters(parametri); this.rpvPreglednik.RefreshReport(); }
public Report(int iid, ReportParameterCollection reports) { InitializeComponent(); btnBack.Visible = false; com = new common(); data_Access = new Data_Access(iid); reportViewer1.LocalReport.DataSources.Clear(); ReportDataSource rds = new ReportDataSource("Wieghts", data_Access.getReportData()); reportViewer1.LocalReport.DataSources.Add(rds); this.reportViewer1.LocalReport.ReportPath = "Reports\\Rep_weight.rdlc"; this.reportViewer1.LocalReport.SetParameters(reports); this.reportViewer1.RefreshReport(); }
private void btnPreview_Click(object sender, EventArgs e) { Save(); ToWord word = new ToWord(Convert.ToDecimal(finalWieght()), new CurrencyInfo(CurrencyInfo.Currencies.Kilo)); ReportParameterCollection reportParameter = new ReportParameterCollection(); reportParameter.Add(new ReportParameter("toArabic", word.ConvertToArabic())); reportParameter.Add(new ReportParameter("User", Properties.Settings.Default.username)); Report report = new Report(Convert.ToInt32(lblCode.Text), reportParameter); report.Show(); Hide(); }
public void InitParameters(LocalReport localReport, object o) { PropertyInfo[] props = o.GetType().GetProperties(); ReportParameterCollection reportParameters = new ReportParameterCollection(); foreach (PropertyInfo prop in props) { var nombre = prop.Name; var value = prop.GetValue(o, null); reportParameters.Add(new ReportParameter(nombre, "" + value)); } localReport.SetParameters(reportParameters); localReport.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted)); }
public void prt_원자재재고현황(DataTable dt, string sDay1, string sCondition) { lblMsg.Visible = true; Application.DoEvents(); try { if (dt != null && dt.Rows.Count > 0) { if (sCondition == "원자재재고현황") { this.reportViewer1.Reset(); this.reportViewer1.LocalReport.DisplayName = "원자재재고현황"; this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Reports\\rpt원자재재고현황.rdlc"; ReportDataSource ds = new ReportDataSource("DataSet1", dt); this.reportViewer1.LocalReport.DataSources.Add(ds); ReportParameterCollection rptParams = new ReportParameterCollection(); rptParams.Add(new ReportParameter("p제목", "원자재재고현황")); //rptParams.Add(new ReportParameter("p견적구분", "아래와 같이 견적합니다.")); rptParams.Add(new ReportParameter("p검색조건", "검색일자 : " + sDay1)); this.reportViewer1.LocalReport.SetParameters(rptParams); } ReportPageSettings rpg = reportViewer1.LocalReport.GetDefaultPageSettings(); System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings(); pg.PaperSize = rpg.PaperSize; pg.Margins = rpg.Margins; pg.Landscape = false; // false = 세로, true = 가로 reportViewer1.SetPageSettings(pg); this.reportViewer1.RefreshReport(); this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); this.reportViewer1.ZoomMode = ZoomMode.PageWidth; } } catch (Exception ex) { wnLog.writeLog(wnLog.LOG_ERROR, ex.Message + " - " + ex.ToString()); MessageBox.Show("시스템에 문제가 있습니다."); this.Hide(); } lblMsg.Visible = false; }
/// <summary> /// 生成部门报告 /// </summary> /// <param name="dsfd">dzhg</param> /// <returns></returns> public Result GeneratingReports() { //获取报告地址 string modelFileName = "满意度-药明.rdl"; string modelPath = Path.Combine(ModelPath, modelFileName); //开始生成报告 return(RunFun((logPath) => { WriteLog(logPath, "开始生成报告"); //绑定 CompanyID,FormApplicationID,FormID ReportParameterCollection col = ToolReport.BindPara(modelPath, Convert.ToInt32(FormID), false); //获取BUList string prefix = GetSqlParam(); DataTable buList = DbContent.GetTable(prefix + BUListSQL); //BU循环 foreach (DataRow buRow in buList.Rows) { string bu = buRow.ItemArray[0].ToString(); WriteLog(logPath, $"当前BU:{bu}"); long time = Watch(() => { string departmentListSQL = DepartmentListSQL.Replace("{BU}", $"'{bu}'"); DataTable departmentList = DbContent.GetTable(prefix + departmentListSQL); //Department循环 foreach (DataRow departmentRow in departmentList.Rows) { string department = departmentRow.ItemArray[0].ToString(); WriteLog(logPath, $"当前Department:{department}"); //绑定 BU,Department参数 col.Add(new ReportParameter("BU", bu)); col.Add(new ReportParameter("Department", department)); // 绑定默认参数 col = ToolReport.BindPara(modelPath, col); //生成部门报告 ToolReport.GenerateLocalReport(modelPath, Path.Combine(DataStarPath, bu) + "\\", $"Biologics-满意度-{department}.pdf", col, true); WriteLog(logPath, $"Biologics-满意度-{department}.pdf 报告生成完毕"); } }); } WriteLog(logPath, "报告生成完毕"); return Res; })); }
protected void Report_Execution(object sender, DirectEventArgs e) { string formatoSalida = ""; try { ReporteLogic reporteLogic = new ReporteLogic(); List<reporte_movimientos_de_inventario_de_cafe_de_socios> ReporteMovimientosInventarioDeCafeDeSociosLst = reporteLogic.GetMovimientosInventarioDeCafeDeSocios (this.f_SOCIOS_ID.Text, string.IsNullOrEmpty(this.f_CLASIFICACIONES_CAFE_ID.Text) ? 0 : Convert.ToInt32(this.f_CLASIFICACIONES_CAFE_ID.Text), this.f_DESCRIPCION.Text, this.f_FECHA.Text, this.f_DATE_FROM.SelectedDate, this.f_DATE_TO.SelectedDate, this.f_CREADO_POR.Text, this.f_FECHA_CREACION.SelectedDate); ReportDataSource datasourceMovimientoInventarioCafeSocios = new ReportDataSource("MovimientosInventarioDeCafeDeSociosDataSet", ReporteMovimientosInventarioDeCafeDeSociosLst); ReportParameterCollection reportParamCollection = new ReportParameterCollection(); reportParamCollection.Add(new ReportParameter("parGroupBySocios", this.g_SOCIOS_ID.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByClasificacionCafe", this.g_CLASIFICACIONES_CAFE_ID.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByDescripcion", this.g_DESCRIPCION.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByFecha", this.g_FECHA.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByCreadoPor", this.g_CREADO_POR.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByFechaCreacion", this.g_FECHA_CREACION.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parMostrarQuintales", this.p_QUINTALES.Checked.ToString())); formatoSalida = this.f_SALIDA_FORMATO.Text; string rdlPath = "~/resources/rdlcs/ReporteMovimientosDeInventarioDeCafeDeSocios.rdlc"; this.CreateFileOutput("ReporteMovimientosInventarioDeCafeDeSocios", formatoSalida, rdlPath, datasourceMovimientoInventarioCafeSocios, reportParamCollection); } catch (Exception ex) { log.Fatal(string.Format("Error fatal al generar reporte. Formato de salida: {0}", formatoSalida), ex); throw; } }
protected void Report_Execution(object sender, DirectEventArgs e) { string formatoSalida = ""; try { ReporteLogic reporteLogic = new ReporteLogic(); List<reporte_detalle_de_aportaciones_por_socio> ReporteDetalleAportacionesXSocioLst = reporteLogic.GetDetalleAportacionesPorSocio (this.f_SOCIOS_ID.Text, this.f_DESCRIPCION.Text, this.f_FECHA.Text, this.f_DATE_FROM.SelectedDate, this.f_DATE_TO.SelectedDate, this.f_CREADO_POR.Text, this.f_FECHA_CREACION.SelectedDate); ReportDataSource datasourceDetalleAportacionesXSocio = new ReportDataSource("DetalleAportacionesPorSocioDataSet", ReporteDetalleAportacionesXSocioLst); ReportParameterCollection reportParamCollection = new ReportParameterCollection(); reportParamCollection.Add(new ReportParameter("parGroupBySocios", this.g_SOCIOS_ID.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByDescripcion", this.g_DESCRIPCION.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByFecha", this.g_FECHA.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByCreadoPor", this.g_CREADO_POR.Checked.ToString())); reportParamCollection.Add(new ReportParameter("parGroupByFechaCreacion", this.g_FECHA_CREACION.Checked.ToString())); formatoSalida = this.f_SALIDA_FORMATO.Text; string rdlPath = "~/resources/rdlcs/ReporteDetalleDeAportacionesPorSocio.rdlc"; this.CreateFileOutput("ReporteDetalleAportacionesPorSocio", formatoSalida, rdlPath, datasourceDetalleAportacionesXSocio, reportParamCollection); } catch (Exception ex) { log.Fatal(string.Format("Error fatal al generar reporte. Formato de salida: {0}", formatoSalida), ex); throw; } }
/// <summary> /// Crea un archivo de reporte para enviar al usuario. /// </summary> /// <param name="fileName"></param> /// <param name="format"></param> /// <param name="RDL_Path"></param> /// <param name="RptDatasource"></param> /// <param name="RptParams"></param> protected void CreateFileOutput(string fileName, string format, string RDL_Path, ReportDataSource RptDatasource, ReportParameterCollection RptParams) { try { // Variables Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty; string extension = string.Empty; // Setup the report viewer object and get the array of bytes ReportViewer viewer = new ReportViewer(); viewer.SizeToReportContent = true; viewer.ProcessingMode = ProcessingMode.Local; viewer.LocalReport.ReportPath = Server.MapPath(RDL_Path); viewer.LocalReport.SetParameters(RptParams); viewer.LocalReport.DataSources.Add(RptDatasource); byte[] bytes = viewer.LocalReport.Render(format, null, out mimeType, out encoding, out extension, out streamIds, out warnings); // Now that you have all the bytes representing the PDF report, buffer it and send it to the client. Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension); Response.BinaryWrite(bytes); // create the file Response.Flush(); // send it to the client to download } catch (Exception ex) { log.Fatal("Error fatal al obtener reporte.", ex); throw; } }
private void CargarReporte() { IdCliente = IdCliente ?? 0; ReportParameterCollection ReportParameters = new ReportParameterCollection(); ReportParameters.Add(new ReportParameter("F_Desde", F_Desde.HasValue ? F_Desde.Value.ToShortDateString() : "")); ReportParameters.Add(new ReportParameter("F_Hasta", F_Hasta.HasValue ? F_Hasta.Value.ToShortDateString() : "")); ReportDataSource source = new ReportDataSource(); source.Name = "FacturaDataset"; source.Value = CargarFacturas(IdCliente, F_Desde, F_Hasta).Value; reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(source); reportViewer1.LocalReport.ReportEmbeddedResource = "rptReporteFacturas.rdlc"; reportViewer1.LocalReport.ReportPath = @"Reportes/rptReporteFacturas.rdlc"; reportViewer1.LocalReport.SetParameters(ReportParameters); reportViewer1.LocalReport.Refresh(); this.reportViewer1.RefreshReport(); }
private void SetParametersValues(string applianceId) { ReportParameter applianceParam = new ReportParameter(); ReportParameter temperatureParam = new ReportParameter(); ReportParameter RHParam = new ReportParameter(); ReportParameter diffPressureParam = new ReportParameter(); IRepository<Appliance> dbA = new ApplianceRepository(); IRepository<SignalAppliance> dbSA = new SignalApplianceRepository(); IRepository<SignalApplianceValue> dbSAV = new SignalApplianceValueRepository(); applianceParam = new ReportParameter("ApplianceParam", "N/A"); temperatureParam = new ReportParameter("TemperatureParam", "0"); RHParam = new ReportParameter("RHParam", "0"); diffPressureParam = new ReportParameter("DiffPressureParam", "0"); Appliance appliance = dbA.GetById(int.Parse(applianceId)); if (appliance == null) { if (int.Parse(applianceId) < 0) { applianceParam = new ReportParameter("ApplianceParam", "TODOS"); temperatureParam = new ReportParameter("TemperatureParam", "Todos"); RHParam = new ReportParameter("RHParam", "Todos"); diffPressureParam = new ReportParameter("DiffPressureParam", "Todos"); } } else { applianceParam = new ReportParameter("ApplianceParam", appliance.NameAppliance); var arrayDiffPressureParam = new ArrayList(); var arrayTemperatureParam = new ArrayList(); var arrayRHParam = new ArrayList(); Dictionary<string, object> properties = new Dictionary<string, object>(); properties.Add("Appliance.Id", int.Parse(applianceId)); IList<SignalAppliance> signalApplianceList = dbSA.GetByProperties(properties); foreach (var signalAppliance in signalApplianceList) { Dictionary<string, object> propertiesSA = new Dictionary<string, object>(); propertiesSA.Add("SignalAppliance.Id", signalAppliance.Id); propertiesSA.Add("AlarmType.Id", int.Parse(ConfigurationManager.AppSettings["NormalAlarmId"])); IList<SignalApplianceValue> signalApplianceValueList = dbSAV.GetByProperties(propertiesSA); foreach (var signalApplianceValue in signalApplianceValueList.OrderByDescending(o => o.Value)) { if (signalAppliance.Signal.Id == SMCLSignals.DifferentialPressure) { arrayDiffPressureParam.Add(signalApplianceValue.Value); arrayDiffPressureParam.Add(signalAppliance.Tolerance); } if (signalAppliance.Signal.Id == SMCLSignals.Temperature) { arrayTemperatureParam.Add(signalApplianceValue.Value); arrayTemperatureParam.Add(signalAppliance.Tolerance); } if (signalAppliance.Signal.Id == SMCLSignals.RH) { arrayRHParam.Add(signalApplianceValue.Value); arrayRHParam.Add(signalAppliance.Tolerance); } } } if (arrayDiffPressureParam.Count > 0) { diffPressureParam = new ReportParameter("DiffPressureParam", arrayDiffPressureParam[0].ToString() + " ± " + arrayDiffPressureParam[1].ToString() + " " + ConfigurationManager.AppSettings["InchesOfWater"]); } if (arrayTemperatureParam.Count > 0) { temperatureParam = new ReportParameter("TemperatureParam", arrayTemperatureParam[0].ToString() + " ± " + arrayTemperatureParam[1].ToString() + " " + ConfigurationManager.AppSettings["DegreeCelsius"]); } if (arrayRHParam.Count > 0) { RHParam = new ReportParameter("RHParam", arrayRHParam[0].ToString() + " ± " + arrayRHParam[1].ToString() + " " + ConfigurationManager.AppSettings["Percentage"]); } } ReportParameterCollection parameters = new ReportParameterCollection(); parameters.Add(applianceParam); parameters.Add(temperatureParam); parameters.Add(RHParam); parameters.Add(diffPressureParam); ReportViewer1.LocalReport.SetParameters(parameters); }
private void GetReportData() { if (reportServerUrl.Value.Length != 0 && reportPath.Value.Length != 0) { var criteriaController = Master.CurrentCriteria(); int selectedDitsrictID = DataIntegrity.ConvertToInt(criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("DistrictID").Select(x => x.Text).FirstOrDefault()); string selectedDistrictName = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("DistrictName").Select(x => x.Text).FirstOrDefault(); string selectedRegion = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("Region").Select(x => x.Text).FirstOrDefault(); int selectedSchoolID = loggedSchoolID == 0 ? DataIntegrity.ConvertToInt(criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("SchoolID").Select(x => x.Text).FirstOrDefault()) : loggedSchoolID; string selectedSchoolName = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("SchoolName").Select(x => x.Text).FirstOrDefault(); string selectedTeacherCertID = null; string selectedTeacherFirstName = loggedTeacherFirstName == null ? criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("TeacherFirstName").Select(x => x.Text).FirstOrDefault() : loggedTeacherFirstName; string selectedTeacherLastName = loggedTeacherLastName == null ? criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("TeacherLastName").Select(x => x.Text).FirstOrDefault() : loggedTeacherLastName; string selectedCourseID = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("CourseID").Select(x => x.Text).FirstOrDefault(); string selectedCourseName = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("CourseName").Select(x => x.Text).FirstOrDefault(); int selectedSectionID = DataIntegrity.ConvertToInt(criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("SectionID").Select(x => x.Text).FirstOrDefault()); int selectedGTID = DataIntegrity.ConvertToInt(criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("GTID").Select(x => x.Text).FirstOrDefault()); string selectedStudentFirstName = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("StudentFirstName").Select(x => x.Text).FirstOrDefault(); string selectedStudentLastName = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("StudentLastName").Select(x => x.Text).FirstOrDefault(); string selectedPreAssessment = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("PreAssessment").Select(x => x.Text).FirstOrDefault(); string selectedMeetsTarget = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("MeetsTarget").Select(x => x.Text).FirstOrDefault(); string selectedExceedsTarget = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("ExceedsTarget").Select(x => x.Text).FirstOrDefault(); string selectedPostAssessment = criteriaController.ParseCriteria<E3Criteria.DropDownList.ValueObject>("PostAssessment").Select(x => x.Text).FirstOrDefault(); var reportParameter = new ReportParameterCollection(); reportParameter.Add(new ReportParameter("DistrictID", selectedDitsrictID == 0 ? null : selectedDitsrictID.ToString())); reportParameter.Add(new ReportParameter("DistrictName", selectedDistrictName)); reportParameter.Add(new ReportParameter("Cluster", selectedRegion)); reportParameter.Add(new ReportParameter("SchoolID", selectedSchoolID == 0 ? null : selectedSchoolID.ToString())); reportParameter.Add(new ReportParameter("SchoolName", selectedSchoolName)); reportParameter.Add(new ReportParameter("TeacherCertID", selectedTeacherCertID)); reportParameter.Add(new ReportParameter("TeacherFirstName", selectedTeacherFirstName)); reportParameter.Add(new ReportParameter("TeacherLastName", selectedTeacherLastName)); reportParameter.Add(new ReportParameter("CourseID", selectedCourseID)); reportParameter.Add(new ReportParameter("CourseName", selectedCourseName)); reportParameter.Add(new ReportParameter("SectionID", selectedSectionID == 0 ? null : selectedSectionID.ToString())); reportParameter.Add(new ReportParameter("GTID", selectedGTID == 0 ? null : selectedGTID.ToString())); reportParameter.Add(new ReportParameter("StudentFirstName", selectedStudentFirstName)); reportParameter.Add(new ReportParameter("StudentLastName", selectedStudentLastName)); reportParameter.Add(new ReportParameter("PreAssessment", selectedPreAssessment)); reportParameter.Add(new ReportParameter("MeetsTarget", selectedMeetsTarget)); reportParameter.Add(new ReportParameter("ExceedsTarget", selectedExceedsTarget)); reportParameter.Add(new ReportParameter("PostAssessment", selectedPostAssessment)); rptViewer.ProcessingMode = ProcessingMode.Remote; rptViewer.ServerReport.ReportServerUrl = new Uri(reportServerUrl.Value); rptViewer.ServerReport.ReportPath = reportPath.Value; rptViewer.ServerReport.ReportServerCredentials = new CustomReportCredentials(reportUsername.Value, reportPassword.Value, reportDomain.Value); rptViewer.ShowParameterPrompts = false; rptViewer.ShowPrintButton = false; rptViewer.ShowRefreshButton = false; rptViewer.ShowBackButton = false; rptViewer.ServerReport.SetParameters(reportParameter); rptViewer.ServerReport.Refresh(); var ajaxPnl = (RadAjaxPanel)Master.FindControl("AjaxPanelResults"); ajaxPnl.Height = System.Web.UI.WebControls.Unit.Pixel(20); } }
private void FrmMatchReport_Load(object sender, EventArgs e) { string leagueName; string hallName; int hallCapacity; string city; string spectators; string date; string time; string supervizor; string scorer; string timeKeeper; using(var db = new MatchReporterEntities()) { leagueName = db.Match.Where(m => m.MatchId == this.Match.MatchId).FirstOrDefault().League.Name; hallName = db.Match.Where(m => m.MatchId == this.Match.MatchId).FirstOrDefault().Hall.Name; hallCapacity = db.Match.Where(m => m.MatchId == this.Match.MatchId).FirstOrDefault().Hall.Capacity; city = db.Hall.Where(h => h.Name == hallName).FirstOrDefault().City.Name; Delegate supervizorObject = db.Delegate.Where(d => d.DelegateId == this.Match.DelegateId).FirstOrDefault(); supervizor = supervizorObject.FirstName + " " + supervizorObject.LastName; } spectators = this.Match.Spectators.ToString() + "/" + hallCapacity.ToString(); date = this.Match.Date.ToShortDateString(); string hours = this.Match.Time.Hours.ToString(); string minutes = this.Match.Time.Minutes.ToString(); if(this.Match.Time.Hours < 10) { hours = "0" + this.Match.Time.Hours.ToString(); } if(this.Match.Time.Minutes < 10) { minutes = "0" + this.Match.Time.Minutes.ToString(); } time = hours + ":" + minutes; scorer = this.Match.Scorer; timeKeeper = this.Match.TimeKeeper; this.HomeTeamPlayerBindingSource.DataSource = this.HomeTeamPlayers; this.GuestTeamPlayerBindingSource.DataSource = this.GuestTeamPlayers; this.HomeTeamOfficialBindingSource.DataSource = this.HomeTeamOfficials; this.GuestTeamOfficialBindingSource.DataSource = this.GuestTeamOfficials; ReportParameterCollection parameters = new ReportParameterCollection(); parameters.Add(new ReportParameter("MatchId", this.Match.MatchId.ToString())); parameters.Add(new ReportParameter("Round", this.Match.Round.ToString())); parameters.Add(new ReportParameter("LeagueName", leagueName)); parameters.Add(new ReportParameter("HallName", hallName + ", " + city)); parameters.Add(new ReportParameter("Spectators", spectators)); parameters.Add(new ReportParameter("Date", date)); parameters.Add(new ReportParameter("Time", time)); parameters.Add(new ReportParameter("HomeTeamName", this.HomeClub.Name)); parameters.Add(new ReportParameter("GuestTeamName", this.GuestClub.Name)); parameters.Add(new ReportParameter("HomeTeamGoals", this.HomeTeam.Goals.ToString())); parameters.Add(new ReportParameter("GuestTeamGoals", this.GuestTeam.Goals.ToString())); parameters.Add(new ReportParameter("HomeTeamTTO1", this.HomeTeam.TTO1 != null ? this.HomeTeam.TTO1 : " /")); parameters.Add(new ReportParameter("HomeTeamTTO2", this.HomeTeam.TTO2 != null ? this.HomeTeam.TTO2 : " /")); parameters.Add(new ReportParameter("HomeTeamTTO3", this.HomeTeam.TTO3 != null ? this.HomeTeam.TTO3 : " /")); parameters.Add(new ReportParameter("GuestTeamTTO1", this.GuestTeam.TTO1 != null ? this.GuestTeam.TTO1 : " /")); parameters.Add(new ReportParameter("GuestTeamTTO2", this.GuestTeam.TTO2 != null ? this.GuestTeam.TTO2 : " /")); parameters.Add(new ReportParameter("GuestTeamTTO3", this.GuestTeam.TTO3 != null ? this.GuestTeam.TTO3 : " /")); parameters.Add(new ReportParameter("RefereePair", refereePairName)); parameters.Add(new ReportParameter("Delegate", supervizor)); parameters.Add(new ReportParameter("Scorer", scorer)); parameters.Add(new ReportParameter("TimeKeeper", timeKeeper)); parameters.Add(new ReportParameter("HomeTeam7m", this.HomeTeam.Goals7m.ToString() + "/" + this.HomeTeam.Attempts7m.ToString())); parameters.Add(new ReportParameter("GuestTeam7m", this.GuestTeam.Goals7m.ToString() + "/" + this.GuestTeam.Attempts7m.ToString())); this.matchReport.LocalReport.SetParameters(parameters); this.matchReport.RefreshReport(); }
private void frmReport_Load(object sender, EventArgs e) { if (!SharedData.bExportMultiple && SharedData.drExportInspection != null) { int iItem = Convert.ToInt32(SharedData.drExportInspection["item"]); int iSchedule = Convert.ToInt32(SharedData.drExportInspection["schedule"]); DataSet dItem = Program.SQL.SelectAll("SELECT * FROM items WHERE id=" + iItem + ";"); DataSet dSchedule = Program.SQL.SelectAll("SELECT grade,type FROM schedules WHERE id=" + iSchedule + ";"); DataRow dIt = dItem.Tables[0].Rows[0], dSc = dSchedule.Tables[0].Rows[0]; DataRow dIn = SharedData.drExportInspection; SharedData.drExportInspection = null; int iInspection = dIn["id"] != DBNull.Value ? Convert.ToInt32(dIn["id"]) : 0; if (iInspection > 0) { DataSet ds = new DataSet(), d; DataTable dt = new DataTable("inspection"); dt.Columns.Add("inspection"); ds.Tables.Add(dt); //rv.LocalReport.ReportPath = Properties.Settings.Default.PathToData + @"\templates\inspections_" + dSchedule.Tables[0].Rows[0]["type"].ToString().ToLower(); rv.LocalReport.ReportEmbeddedResource = "Client.Reports.rptInspection" + dSc["type"].ToString().ToUpper() + ".rdlc"; rv.LocalReport.DataSources.Clear(); string sInspector = ""; int iInspector = dIn["inspector"].ToString() != "" && dIn["inspector"].ToString().All(char.IsDigit) ? Convert.ToInt32(dIn["inspector"]) : 0; if (iInspector > 0) { d = Program.SQL.SelectAll("SELECT name_first,name_last FROM users WHERE id=" + iInspector + ";"); if (d.Tables.Count == 1 && d.Tables[0].Rows.Count == 1) { sInspector = d.Tables[0].Rows[0]["name_first"].ToString() + " " + d.Tables[0].Rows[0]["name_last"].ToString(); } } string sLocation1 = "", sLocation2 = "", sLocationSite = "", sLocationArea = "", sLocationVessel = "", sLocationFloor = "", sLocationGrid = ""; if (dIt["locationsite"].ToString() != "" && dIt["locationsite"].ToString().All(char.IsDigit)) { d = Program.SQL.SelectAll("SELECT name FROM locations_sites WHERE id=" + dIt["locationsite"].ToString() + ";"); if (d.Tables.Count == 1 && d.Tables[0].Rows.Count == 1) { sLocationSite = d.Tables[0].Rows[0]["name"].ToString(); } } if (dIt["locationarea"].ToString() != "" && dIt["locationarea"].ToString().All(char.IsDigit)) { d = Program.SQL.SelectAll("SELECT name FROM locations_areas WHERE id=" + dIt["locationarea"].ToString() + ";"); if (d.Tables.Count == 1 && d.Tables[0].Rows.Count == 1) { sLocationArea = d.Tables[0].Rows[0]["name"].ToString(); } } if (dIt["locationvessel"].ToString() != "" && dIt["locationvessel"].ToString().All(char.IsDigit)) { d = Program.SQL.SelectAll("SELECT name FROM locations_vessels WHERE id=" + dIt["locationvessel"].ToString() + ";"); if (d.Tables.Count == 1 && d.Tables[0].Rows.Count == 1) { sLocationVessel = d.Tables[0].Rows[0]["name"].ToString(); } } if (dIt["locationfloor"].ToString() != "" && dIt["locationfloor"].ToString().All(char.IsDigit)) { d = Program.SQL.SelectAll("SELECT name FROM locations_floors WHERE id=" + dIt["locationfloor"].ToString() + ";"); if (d.Tables.Count == 1 && d.Tables[0].Rows.Count == 1) { sLocationFloor = d.Tables[0].Rows[0]["name"].ToString(); } } if (dIt["locationgrid"].ToString() != "" && dIt["locationgrid"].ToString().All(char.IsDigit)) { d = Program.SQL.SelectAll("SELECT name FROM locations_grids WHERE id=" + dIt["locationgrid"].ToString() + ";"); if (d.Tables.Count == 1 && d.Tables[0].Rows.Count == 1) { sLocationGrid = d.Tables[0].Rows[0]["name"].ToString(); } } sLocation1 = sLocationSite.Length > 0 ? "Site: " + sLocationSite : ""; sLocation1 += sLocationArea.Length > 0 ? (sLocation1.Length > 0 ? "; " : "") + "Area: " + sLocationArea : ""; sLocation1 += sLocationVessel.Length > 0 ? (sLocation1.Length > 0 ? "; " : "") + "Vessel: " + sLocationVessel : ""; sLocation2 = sLocationFloor.Length > 0 ? "Floor: " + sLocationFloor : ""; sLocation2 += sLocationGrid.Length > 0 ? (sLocation1.Length > 0 ? "; " : "") + "Grid: " + sLocationGrid : ""; string sManufacturer = ""; int iManufacturer = dIt["manufacturer"].ToString() != "" ? Convert.ToInt32(dIt["manufacturer"]) : 0; if (iManufacturer > 0) { d = Program.SQL.SelectAll("SELECT name FROM lists_manufacturers WHERE id=" + iManufacturer + ";"); if (d.Tables.Count == 1 && d.Tables[0].Rows.Count == 1) { sManufacturer = d.Tables[0].Rows[0]["name"].ToString(); } } string sDrawingHac = ""; int iDrawingHac = dIt["drawing_hac"].ToString() != "" ? Convert.ToInt32(dIt["drawing_hac"]) : 0; if (iDrawingHac > 0) { d = Program.SQL.SelectAll("SELECT name,revision,date FROM lists_drawings_hac WHERE id=" + iDrawingHac + ";"); if (d.Tables.Count == 1 && d.Tables[0].Rows.Count == 1) { sDrawingHac = d.Tables[0].Rows[0]["name"].ToString(); sDrawingHac += d.Tables[0].Rows[0]["revision"].ToString() != "" ? " Rev. " + d.Tables[0].Rows[0]["revision"].ToString() : ""; sDrawingHac += d.Tables[0].Rows[0]["date"].ToString() != "" ? " (" + Convert.ToDateTime(d.Tables[0].Rows[0]["date"]).ToShortDateString() + ")" : ""; } } string sAtexProtection = dIt["atex_protection"].ToString() != "" ? "Protection: " + dIt["atex_protection"].ToString() : ""; sAtexProtection += dIt["atex_group"].ToString() != "" ? (sAtexProtection.Length > 0 ? "; " : "") + dIt["atex_group"].ToString() : ""; sAtexProtection += dIt["atex_category"].ToString() != "" ? (sAtexProtection.Length > 0 ? "; " : "") + dIt["atex_category"].ToString() : ""; string sHacZone = dIt["area_zone"].ToString() != "" ? "Zone: " + dIt["area_zone"].ToString() : ""; sHacZone += dIt["area_group"].ToString() != "" ? (sHacZone.Length > 0 ? "; " : "") + "Group: " + dIt["area_group"].ToString() : ""; sHacZone += dIt["area_trating"].ToString() != "" ? (sHacZone.Length > 0 ? "; " : "") + "T-Rating: " + dIt["area_trating"].ToString() : ""; ReportParameterCollection p = new ReportParameterCollection(); // INSPECTION p.Add(new ReportParameter("inspection", iInspection.ToString())); p.Add(new ReportParameter("workorder", dIn["workorder"].ToString() != "" ? dIn["workorder"].ToString() : "")); p.Add(new ReportParameter("inspector", sInspector)); // ITEM p.Add(new ReportParameter("location1", sLocation1)); p.Add(new ReportParameter("location2", sLocation2)); p.Add(new ReportParameter("locationall", (sLocation1 != "" && sLocation2 != "" ? sLocation1 + "; " + sLocation2 : (sLocation1 != "" ? sLocation1 : sLocation2)))); p.Add(new ReportParameter("description", dIt["description"].ToString() != "" ? dIt["description"].ToString() : "")); p.Add(new ReportParameter("manufacturer", sManufacturer)); p.Add(new ReportParameter("serial", dIt["serial"].ToString() != "" ? dIt["serial"].ToString() : "")); p.Add(new ReportParameter("barrier", dIt["barrier"].ToString() != "" ? dIt["barrier"].ToString() : "")); p.Add(new ReportParameter("mtype", dIt["type_model"].ToString() != "" ? dIt["type_model"].ToString() : "")); p.Add(new ReportParameter("drawinghac", sDrawingHac)); p.Add(new ReportParameter("drawingdl", dIt["drawing_device_loop"].ToString() != "" ? dIt["drawing_device_loop"].ToString() : "")); p.Add(new ReportParameter("atexprot", sAtexProtection)); p.Add(new ReportParameter("atexcert", dIt["cert_equipment"].ToString() != "" ? dIt["cert_equipment"].ToString() : "")); p.Add(new ReportParameter("ptype", dIt["type_protection"].ToString() != "" ? dIt["type_protection"].ToString() : "")); p.Add(new ReportParameter("haczone", sHacZone)); p.Add(new ReportParameter("tracehc", dIt["cpref"].ToString() == "y" ? "Yes" : "No")); p.Add(new ReportParameter("cpref", dIt["cpref"].ToString() != "" ? dIt["cpref"].ToString() : "")); // ANSWERS DataSet at = Program.SQL.SelectAll("SELECT id,question,part,answer FROM inspections_answers WHERE inspection=" + iInspection + ";"); if (at.Tables.Count == 1 && at.Tables[0].Rows.Count > 0) { DataSet st = Program.SQL.SelectAll("SELECT questions FROM schedules WHERE id=" + iSchedule + ";"); if (st.Tables.Count == 1 && st.Tables[0].Rows.Count > 0 && st.Tables[0].Rows[0]["questions"].ToString() != "") { List<string> lQuestions = new List<string>(); string[] sQIDs = st.Tables[0].Rows[0]["questions"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string sQ in sQIDs) { string sQuestion = sQ.IndexOf(':') > 0 ? sQ.Substring(0, sQ.IndexOf(':')) : sQ; if (!lQuestions.Contains(sQuestion)) { lQuestions.Add(sQuestion); } } DataSet qt = Program.SQL.SelectAll("SELECT id,section,letter,number,question,parts FROM schedules_questions WHERE id IN (" + string.Join(",", lQuestions) + ");"); if (qt.Tables.Count == 1 && qt.Tables[0].Rows.Count > 0) { foreach (DataRow qr in qt.Tables[0].Rows) { string sAnswer = ""; string sQRef = qr["letter"].ToString() + dSc["grade"] + Convert.ToInt32(qr["number"]).ToString(); string[] sParts = qr["parts"] != DBNull.Value ? qr["parts"].ToString().TrimStart('{').TrimEnd('}').Split(new char[] { '}', '{' }, StringSplitOptions.RemoveEmptyEntries) : new string[] { }; foreach (DataRow ar in at.Tables[0].Rows) { if (ar["question"].ToString() == qr["id"].ToString()) { sAnswer = ar["answer"].ToString(); if (sParts.Length > 0) { for (int i = 0; i < sParts.Length; i++) { if (ar["part"].ToString() != (i + 1).ToString()) { continue; } sQRef = qr["letter"].ToString() + dSc["grade"] + Convert.ToInt32(qr["number"]).ToString() + "_" + (i + 1); p.Add(new ReportParameter(sQRef, sAnswer)); } } else { p.Add(new ReportParameter(sQRef, sAnswer)); } } } } } } } // FAULTS string[] sFaults = new string[] { "", "", "", "" }; DataSet ft = Program.SQL.SelectAll("SELECT id,question,part,fault,priority FROM inspections_faults WHERE inspection=" + iInspection + ";"); if (ft.Tables.Count == 1 && ft.Tables[0].Rows.Count > 0) { foreach (DataRow fr in ft.Tables[0].Rows) { if (!fr["priority"].ToString().Equals("o")) { DataSet st = Program.SQL.SelectAll("SELECT questions FROM schedules WHERE id=" + iSchedule + ";"); if (st.Tables.Count == 1 && st.Tables[0].Rows.Count > 0 && st.Tables[0].Rows[0]["questions"].ToString() != "") { List<string> lQuestions = new List<string>(); string[] sQIDs = st.Tables[0].Rows[0]["questions"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string sQ in sQIDs) { string sQuestion = sQ.IndexOf(':') > 0 ? sQ.Substring(0, sQ.IndexOf(':')) : sQ; if (!lQuestions.Contains(sQuestion)) { lQuestions.Add(sQuestion); } } DataSet qt = Program.SQL.SelectAll("SELECT id,section,letter,number,question,parts FROM schedules_questions WHERE id IN (" + string.Join(",", lQuestions) + ");"); if (qt.Tables.Count == 1 && qt.Tables[0].Rows.Count > 0) { foreach (DataRow qr in qt.Tables[0].Rows) { string sQRef = qr["letter"].ToString() + dSc["grade"] + Convert.ToInt32(qr["number"]).ToString(); string[] sParts = qr["parts"] != DBNull.Value ? qr["parts"].ToString().TrimStart('{').TrimEnd('}').Split(new char[] { '}', '{' }, StringSplitOptions.RemoveEmptyEntries) : new string[] { }; if (fr["question"].ToString() == qr["id"].ToString()) { if (sParts.Length > 0) { for (int i = 0; i < sParts.Length; i++) { if (fr["part"].ToString() == (i + 1).ToString()) { string sFault = qr["letter"].ToString() + qr["number"].ToString() + ": " + fr["fault"].ToString(); sFaults[Convert.ToInt32(fr["priority"]) - 1] += (sFaults[Convert.ToInt32(fr["priority"]) - 1].Length > 0 ? "; " : "") + sFault; } } } } } } } } } } p.Add(new ReportParameter("faults1", sFaults[0])); p.Add(new ReportParameter("faults2", sFaults[1])); p.Add(new ReportParameter("faults3", sFaults[2])); p.Add(new ReportParameter("faults4", sFaults[3])); rv.LocalReport.SetParameters(p); rv.LocalReport.DataSources.Add(new ReportDataSource("Inspection", ds.Tables[0])); rv.RefreshReport(); } } }