private void btnShow_Click(object sender, EventArgs e) { string strSelection = ""; CrystalDecisions.CrystalReports.Engine.ReportClass ReportObject; //To Select the data by parameters you shound add here if (!txtSearchingParameter1.Text.Trim().Equals(string.Empty)) { strSelection = strSelection + (strSelection == "" ? "" : " And "); strSelection = strSelection + "{CrystalReportWithVS2012_ReportClasses_ReportData_AMIN_ITEMS.NAME}='" + txtSearchingParameter1.Text.Trim() + "'"; } List <AMIN_ITEMS> list = new List <AMIN_ITEMS>(); list = LoadData(); ReportObject = new TestCrystalReport(); ReportObject.SetDataSource(list); //To show value directly in the crystal report you should add a parameter and submet data like this CrystalDecisions.Shared.ParameterDiscreteValue crParameter1 = new CrystalDecisions.Shared.ParameterDiscreteValue(); crParameter1.Value = txtShowValue1.Text; ReportObject.SetParameterValue("FirstParameter", crParameter1); CrystalDecisions.Shared.ParameterDiscreteValue crParameter2 = new CrystalDecisions.Shared.ParameterDiscreteValue(); crParameter2.Value = txtShowValue2.Text; ReportObject.SetParameterValue("SecondParameter", crParameter2); ReportAccess.ShowReport(ReportObject, strSelection); }
private void AttenreportForm2_Load(object sender, EventArgs e) { ds = hremp.SelectByEmpMonth(_date); DataTable dt = ds.Tables[0]; //DateTime bgdate = Convert.ToDateTime(dt.Rows[0]["ShouldCheckIn"].ToString()); //DateTime endate = Convert.ToDateTime(dt.Rows[0]["ShouldCheckOut"].ToString()); dt.TableName = "attentreport"; CrystalDecisions.Shared.ParameterValues employeename = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue PDEmployeeId = new CrystalDecisions.Shared.ParameterDiscreteValue(); //attenreport.SetParameterValue("beginTime", bgdate.ToString("HH:mm")); //attenreport.SetParameterValue("toTime", endate.ToString("HH:mm")); //CrystalDecisions.Shared.ParameterValues EmployeeName = new CrystalDecisions.Shared.ParameterValues(); //CrystalDecisions.Shared.ParameterDiscreteValue PDEmployeeID = new CrystalDecisions.Shared.ParameterDiscreteValue(); //PDEmployeeID.Value = "EmployeeName"; //EmployeeName.Add(PDEmployeeID); if (hasDepartment) { AttenreportCrystal2 attenreport = new AttenreportCrystal2(); attenreport.SetDataSource(ds); crystalReportViewer1.ReportSource = attenreport; } else { AttenreportCrystal3 attenreport = new AttenreportCrystal3(); attenreport.SetDataSource(ds); crystalReportViewer1.ReportSource = attenreport; } }
private void btnPrint_Click(object sender, EventArgs e) { try { // var rd = new ReportDocument(); // rd.FileName = "crystal files\\OrderReport.rpt"; //// var MainFrmObj = new MainFrm(); // var db = new linqDataContext(); // // rd.SetDataSource(MainFrmObj.common_DBDataSet.ordertbl.DataSet); // rd.SetDataSource(db.ordertbls); // crystalReportViewer.ReportSource = rd; // crystalReportViewer.Show(); // NumberRowOfGridview parametersFields = new CrystalDecisions.Shared.ParameterFields(); parameterField = new CrystalDecisions.Shared.ParameterField(); parameterValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); parameterField.Name = "NumberRowOfGridview"; parameterValue.Value = NumberRowOfGridview; parameterField.CurrentValues.Add(parameterValue); parametersFields.Add(parameterField); crystalReportViewer.ParameterFieldInfo = parametersFields; this.crystalReportViewer.ReportSource = System.IO.Directory.GetCurrentDirectory() + "\\OrderReport.rpt"; // this.crystalReportViewer.RefreshReport(); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
void MostrarReportexPedido(String vMes) { try { CrystalDecisions.Shared.ParameterValues oPvCollection = new CrystalDecisions.Shared.ParameterValues(); //parametro CrystalDecisions.Shared.ParameterDiscreteValue oPdv = new CrystalDecisions.Shared.ParameterDiscreteValue(); //valor del parametro ReportDocument oRptDoc = new ReportDocument(); oPvCollection.Clear(); frmReportes.CR_DespachoProductoxMes rpv = new frmReportes.CR_DespachoProductoxMes(); rpv.SetParameterValue("@Mes", vMes); rpv.SetParameterValue("@Año", cboAño.SelectedItem); crvReporteDespachoProductoxMes.ReportSource = rpv; } catch (LoadSaveReportException) { MessageBox.Show("Ruta incorrecta Verifique la ruta del reporte", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Aviso del Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void Page_Init(object sender, System.EventArgs e) { try { string sPath = HttpContext.Current.Request.MapPath("~/Report\\"); //表示一个报表,并且包含定义、格式化、加载、导出和打印该报表的属性和方法。 CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); CrystalDecisions.Shared.ParameterDiscreteValue discreteVal = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterValues paraValues = new CrystalDecisions.Shared.ParameterValues(); //加载你事先做好的Crystal Report报表文件 Report.Load(sPath + Request.QueryString["ReportName"], CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy); string sData = PublicApi.fnGetConStr("MNDT").Replace(";", ","); // 設定報表內SQL Server資料庫的登入資訊 CrystalDecisions.Shared.TableLogOnInfo logonInfo = new CrystalDecisions.Shared.TableLogOnInfo(); foreach (CrystalDecisions.CrystalReports.Engine.Table table in Report.Database.Tables) { logonInfo = table.LogOnInfo; var _with1 = logonInfo.ConnectionInfo; _with1.ServerName = fnGetData(sData, "Data Source"); _with1.DatabaseName = fnGetData(sData, "Initial Catalog"); _with1.UserID = fnGetData(sData, "User ID"); _with1.Password = fnGetData(sData, "Password"); table.ApplyLogOnInfo(logonInfo); } Report.SetDataSource(Session["PrintDT"]); //Session["PrintDT"] = null; if (Report.ParameterFields["列印人員"] != null) { Report.SetParameterValue("列印人員", Session["sId"]); } if (Report.ParameterFields["進貨稅額"] != null) { string sSql = " SELECT [parameter] " + " FROM [mndtkind_details] " + " WHERE [kind_id] = 'TAX' " + " AND [code_id] = 'IN' "; Report.SetParameterValue("進貨稅額", PublicApi.fnGetValue(sSql, "MNDT")); } CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX; //列印顯示列印選項,但只有IE會出現這功能 //Report.PrintToPrinter(1, true, 0, 0); // 直接列印 CrystalReportViewer1.ReportSource = Report; //CrystalReportViewer1.HasExportButton = false; //將匯出的功能False掉 //CrystalReportViewer1.HasPrintButton = false; //CrystalReportViewer1.HasToggleGroupTreeButton = false; //將樹狀結構的按鈕False掉 //CrystalReportViewer1.DisplayGroupTree = false; //將樹狀結構狀態False掉 } catch (Exception e1) { //Functions.fnMessageBox(e1.ToString(), this); } }
private void AsignarParametros(double p) { CrystalDecisions.Shared.ParameterValues myVals = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue myDiscrete = new CrystalDecisions.Shared.ParameterDiscreteValue(); myDiscrete.Value = NumALet.ToCardinal(Convert.ToDecimal(p)); myVals.Add(myDiscrete); facturaRpt.DataDefinition.ParameterFields[0].ApplyCurrentValues(myVals); facturaRpt.Subreports["resumen"].DataDefinition.FormulaFields["ImpTotTexto"].Text = "'" + NumALet.ToCardinal(Convert.ToDecimal(p)) + "'"; }
public void PrintTicket() { try { CrystalDecisions.CrystalReports.Engine.ReportDocument etq = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string spath = System.Windows.Forms.Application.StartupPath; etq.Load(spath + "\\" + @"\Reports\DRE_v3.RPT"); CrystalDecisions.Shared.IConnectionInfo crConnectionInfo = etq.DataSourceConnections[0]; string DbUser = Properties.Settings.Default.DbUserName; string DbPwd = Properties.Settings.Default.DbPassword; string Server = Properties.Settings.Default.Server; string CompanyDB = Properties.Settings.Default.CompanyDB; crConnectionInfo.SetConnection(Server, CompanyDB, DbUser, DbPwd); //Parametro 0 CrystalDecisions.Shared.ParameterField objParameterField = etq.ParameterFields[0]; CrystalDecisions.Shared.ParameterDiscreteValue objParameterDiscreteValue; objParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); objParameterField.CurrentValues.Clear(); objParameterDiscreteValue.Description = "2017-10-01"; objParameterDiscreteValue.Value = "2017-10-01"; objParameterField.CurrentValues.Add(objParameterDiscreteValue); //Parametro 1 CrystalDecisions.Shared.ParameterField objParameterField1 = etq.ParameterFields[1]; CrystalDecisions.Shared.ParameterDiscreteValue objParameterDiscreteValue1; objParameterDiscreteValue1 = new CrystalDecisions.Shared.ParameterDiscreteValue(); objParameterField1.CurrentValues.Clear(); objParameterDiscreteValue1.Description = "2017-10-31"; objParameterDiscreteValue1.Value = "2017-10-31"; objParameterField1.CurrentValues.Add(objParameterDiscreteValue1); //etq.PrintOptions.PrinterName = Properties.Settings.Default.PrinterNameTerra; etq.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"C:\Temp\RPT.pdf"); etq.Close(); } catch (Exception ex) { } }
private void Form14_Load(object sender, EventArgs e) { CrystalReport3 rapor = new CrystalReport3(); CrystalDecisions.Shared.ParameterValues parametre = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue deger = new CrystalDecisions.Shared.ParameterDiscreteValue(); deger.Value = Form12.kodx; parametre.Add(deger); rapor.DataDefinition.ParameterFields["tcno"].ApplyCurrentValues(parametre); crystalReportViewer1.ReportSource = rapor; }
public void GenerateReport() { try { CrystalDecisions.CrystalReports.Engine.ReportDocument objReport1 = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); CrystalDecisions.Shared.TableLogOnInfos crtableLogoninfos = new CrystalDecisions.Shared.TableLogOnInfos(); CrystalDecisions.Shared.TableLogOnInfo ConInfo = new CrystalDecisions.Shared.TableLogOnInfo(); CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo(); CrystalDecisions.CrystalReports.Engine.Tables CrTables; CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions crParameterFieldDefinitions; CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition crParameterFieldDefinition; CrystalDecisions.Shared.ParameterValues crParameterValues = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); objReport1.Load(LoadReport()); string sUserID = "sa"; string sPassword = "******"; string sServerName = "192.168.1.42"; string sDatabaseName = "BoxControlAndMonitoringDB"; crConnectionInfo.ServerName = sServerName; crConnectionInfo.DatabaseName = sDatabaseName; //crConnectionInfo.IntegratedSecurity = true; crConnectionInfo.UserID = sUserID; crConnectionInfo.Password = sPassword; CrTables = objReport1.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { ConInfo = CrTable.LogOnInfo; ConInfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(ConInfo); } reportViewer.ViewerCore.ReportSource = objReport1; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Reporte_Load(object sender, EventArgs e) { CrystalReport3 objRpt = new CrystalReport3(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\EXCL.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT * FROM Expediente Where Folio = '" + foliom + "'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable2"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; if (areaaf == "Frente") { appPath = Path.GetDirectoryName(Application.ExecutablePath); appPath = appPath + @"\body1.jpg"; } else if (areaaf == "Espalda") { appPath = Path.GetDirectoryName(Application.ExecutablePath); appPath = appPath + @"\body2.jpg"; } DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }
void MostrarReportexPedido(int idOpe, int id) { if (idOpe == 0) { try { CrystalDecisions.Shared.ParameterValues oPvCollection = new CrystalDecisions.Shared.ParameterValues(); //parametro CrystalDecisions.Shared.ParameterDiscreteValue oPdv = new CrystalDecisions.Shared.ParameterDiscreteValue(); //valor del parametro ReportDocument oRptDoc = new ReportDocument(); // oPvCollection.Clear(); frmReportes.CR_ImprimirDespacho rpv = new frmReportes.CR_ImprimirDespacho(); rpv.SetParameterValue("@id", id); crvImprimirPedidoDespacho.ReportSource = rpv; } catch (LoadSaveReportException) { MessageBox.Show("Ruta incorrecta Verifique la ruta del reporte", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Aviso del Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { try { CrystalDecisions.Shared.ParameterValues oPvCollection = new CrystalDecisions.Shared.ParameterValues(); //parametro CrystalDecisions.Shared.ParameterDiscreteValue oPdv = new CrystalDecisions.Shared.ParameterDiscreteValue(); //valor del parametro ReportDocument oRptDoc = new ReportDocument(); // oPvCollection.Clear(); frmReportes.CR_ImprimirPedido rpv = new frmReportes.CR_ImprimirPedido(); rpv.SetParameterValue("@id", id); crvImprimirPedidoDespacho.ReportSource = rpv; } catch (LoadSaveReportException) { MessageBox.Show("Ruta incorrecta Verifique la ruta del reporte", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Aviso del Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void LoadReportTest1() { CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); doc.Load(@"C:\test1.rpt"); this.CrystalReportViewer1.ReportSource = doc; this.CrystalReportViewer1.HasSearchButton = false; this.CrystalReportViewer1.HasZoomFactorList = false; this.CrystalReportViewer1.HasGotoPageButton = false; CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition fieldDef = doc.DataDefinition.ParameterFields["ids_param"]; CrystalDecisions.Shared.ParameterValues vals = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue val = new CrystalDecisions.Shared.ParameterDiscreteValue(); val.Value = 1; vals.Add(val); val = new CrystalDecisions.Shared.ParameterDiscreteValue(); val.Value = 2; vals.Add(val); val = new CrystalDecisions.Shared.ParameterDiscreteValue(); val.Value = 3; vals.Add(val); fieldDef.ApplyCurrentValues(vals); CrystalDecisions.Shared.ConnectionInfo conn = new CrystalDecisions.Shared.ConnectionInfo(); conn.DatabaseName = "DBSALESPP"; conn.ServerName = "."; conn.UserID = "spp"; conn.Password = "******"; CrystalDecisions.Shared.TableLogOnInfo tableLogOn = new CrystalDecisions.Shared.TableLogOnInfo(); tableLogOn.ConnectionInfo = conn; doc.Database.Tables[0].ApplyLogOnInfo(tableLogOn); //System.IO.Stream stream=doc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.HTML32); doc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"c:\test.pdf"); }
public void SetReportPara(CrystalDecisions.Shared.ParameterFields paraDef, string[] repoTitles, string prefix) { CrystalDecisions.Shared.ParameterValues pvCollection = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue pdvHeader = new CrystalDecisions.Shared.ParameterDiscreteValue(); pvCollection.Clear(); //Title string tmp; for (int idx = 0; idx < repoTitles.Length; idx++) { tmp = prefix + idx.ToString().Trim(); if (paraDef[tmp] != null && repoTitles[idx] != null) { pdvHeader.Value = repoTitles[idx]; pvCollection.Add(pdvHeader); paraDef[tmp].CurrentValues = pvCollection; } } }
private void Reporte_Load(object sender, EventArgs e) { CrystalReport3 objRpt = new CrystalReport3(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\EXCL.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT * FROM Expediente Where Folio = '" + foliom + "'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable2"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; if (areaaf == "Frente") { appPath = Path.GetDirectoryName(Application.ExecutablePath); appPath = appPath + @"\body1.jpg"; } else if (areaaf == "Espalda") { appPath = Path.GetDirectoryName(Application.ExecutablePath); appPath = appPath + @"\body2.jpg"; } DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }
public void SetReportPara(CrystalDecisions.Shared.ParameterFields paraDef, string[] repoTitles, string prefix) { CrystalDecisions.Shared.ParameterValues pvCollection = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue pdvHeader = new CrystalDecisions.Shared.ParameterDiscreteValue(); pvCollection.Clear(); //Title string tmp; for (int idx = 0; idx < repoTitles.Length; idx++) { tmp = prefix + idx.ToString().Trim(); if (paraDef[tmp] != null && repoTitles[idx] != null) { pdvHeader.Value = repoTitles[idx]; pvCollection.Add(pdvHeader); paraDef[tmp].CurrentValues = pvCollection; } } }
private void BindReport(string reportName) { CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string reportPath = Server.MapPath(Constz.HomeFolder + "Reports/" + reportName + ".rpt"); rpt.Load(reportPath); CrystalDecisions.Shared.TableLogOnInfo logonInfo = new CrystalDecisions.Shared.TableLogOnInfo(); logonInfo = rpt.Database.Tables[0].LogOnInfo; logonInfo.ConnectionInfo.ServerName = ConfigurationManager.AppSettings["DB_SERVER"].ToString().Trim(); logonInfo.ConnectionInfo.UserID = ConfigurationManager.AppSettings["DB_USER"].ToString().Trim(); logonInfo.ConnectionInfo.Password = ConfigurationManager.AppSettings["DB_PASSWORD"].ToString(); rpt.Database.Tables[0].ApplyLogOnInfo(logonInfo); CrystalDecisions.Shared.ParameterValues curValue = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue paraValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); for (int i = 0; i < Request.QueryString.Count; ++i) { string field = Request["paramfield" + (i + 1).ToString()]; string value = Request["paramvalue" + (i + 1).ToString()]; if (field != null && value != null) { paraValue.Value = value; curValue = rpt.ParameterFields[field].CurrentValues; curValue.Add(paraValue); rpt.ParameterFields[field].CurrentValues = curValue; } else break; } //paraValue.Value = reportKey; //curValue = rpt.ParameterFields["LOID"].CurrentValues; //curValue.Add(paraValue); //rpt.ParameterFields["LOID"].CurrentValues = curValue; rpt.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Auto; if (Request["landscape"] != null) { if (Request["landscape"] == "1") rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape; } Page.Cache["rpt"] = rpt; ctlReportViewer.ReportSource = Page.Cache["rpt"]; //ctlReportViewer.DataBind(); }
void MostrarReportexPedido() { try { CrystalDecisions.Shared.ParameterValues oPvCollection = new CrystalDecisions.Shared.ParameterValues(); //parametro CrystalDecisions.Shared.ParameterDiscreteValue oPdv = new CrystalDecisions.Shared.ParameterDiscreteValue(); //valor del parametro ReportDocument oRptDoc = new ReportDocument(); oPvCollection.Clear(); frmReportes.CR_ProductoxAlmacen rpv = new frmReportes.CR_ProductoxAlmacen(); rpv.SetParameterValue("@nomAlm", this.cboAlmacen.Text); crvProductoxAlmacen.ReportSource = rpv; } catch (LoadSaveReportException) { MessageBox.Show("Ruta incorrecta Verifique la ruta del reporte", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Aviso del Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnVistaPrevia_Click(object sender, System.EventArgs e) { cryRepPromedios1.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait; cryRepPromedios1.SetDataSource(dsPromedios1); try { CrystalDecisions.Shared.ParameterValues pvCollection = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue pdvUnidad = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvUnidad.Value = cmbUnidad.Text; CrystalDecisions.Shared.ParameterDiscreteValue pdvRes = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvRes.Value = float.Parse(dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][1].ToString()) * float.Parse(dsUnidad1.Tables["unidad"].Rows[cmbUnidad.SelectedIndex][2].ToString()); CrystalDecisions.Shared.ParameterDiscreteValue pdvTip = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvTip.Value = dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][2].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvTma = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvTma.Value = dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][3].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvRev = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvRev.Value = dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][4].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvTag = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvTag.Value = dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][5].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvCon = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvCon.Value = cmbConcretera.Text; CrystalDecisions.Shared.ParameterDiscreteValue pdvPla = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvPla.Value = cmbPlanta.Text; CrystalDecisions.Shared.ParameterDiscreteValue pdvCra = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvCra.Value = dsBuscaObra1.Tables["Obra"].Rows[cmbIdObra.SelectedIndex][3].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvObr = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvObr.Value = txtIdobra.Text; CrystalDecisions.Shared.ParameterDiscreteValue pdvZon = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvZon.Value = dsBuscaObra1.Tables["Obra"].Rows[cmbIdObra.SelectedIndex][4].ToString(); pvCollection.Clear(); pvCollection.Add(pdvUnidad); cryRepPromedios1.DataDefinition.ParameterFields["@Unidad"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvRes); cryRepPromedios1.DataDefinition.ParameterFields["@Res"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvTip); cryRepPromedios1.DataDefinition.ParameterFields["@Tip"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvTma); cryRepPromedios1.DataDefinition.ParameterFields["@Tma"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvRev); cryRepPromedios1.DataDefinition.ParameterFields["@Rev"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvTag); cryRepPromedios1.DataDefinition.ParameterFields["@Tag"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvCon); cryRepPromedios1.DataDefinition.ParameterFields["@Con"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvPla); cryRepPromedios1.DataDefinition.ParameterFields["@Pla"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvCra); cryRepPromedios1.DataDefinition.ParameterFields["@Cra"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvObr); cryRepPromedios1.DataDefinition.ParameterFields["@Obr"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvZon); cryRepPromedios1.DataDefinition.ParameterFields["@Zon"].ApplyCurrentValues(pvCollection); } catch (Exception ex1) { MessageBox.Show("parametro" + ex1.Message); } try { for (int x = 0; x < cmbTipo.Items.Count; x++) { if (dsTipo1.Tables[0].Rows[x][1].ToString() == dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][2].ToString()) { cmbTipo.SelectedIndex = x; } } dsPromedios1.Clear(); sqlDAPromedios.SelectCommand.Parameters["@IdObra"].Value = txtIdobra.Text; sqlDAPromedios.SelectCommand.Parameters["@IdConcretera"].Value = cmbConcretera.SelectedValue.ToString(); sqlDAPromedios.SelectCommand.Parameters["@IdPlanta"].Value = cmbPlanta.SelectedValue.ToString(); sqlDAPromedios.SelectCommand.Parameters["@FechaIni"].Value = dtpIni.Text; sqlDAPromedios.SelectCommand.Parameters["@FechaFin"].Value = dtpFin.Text; sqlDAPromedios.SelectCommand.Parameters["@ResistenciaKg"].Value = dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][1].ToString(); sqlDAPromedios.SelectCommand.Parameters["@Tipo"].Value = cmbTipo.SelectedValue; sqlDAPromedios.SelectCommand.Parameters["@Agregado"].Value = dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][3].ToString(); sqlDAPromedios.SelectCommand.Parameters["@Renvenimiento"].Value = dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][4].ToString(); sqlDAPromedios.SelectCommand.Parameters["@IdAgregado"].Value = (dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][5].ToString() == "Normal" ? 1 : 2); sqlDAPromedios.SelectCommand.Parameters["@IdPrueba"].Value = 1; sqlDAPromedios.SelectCommand.Parameters["@IdUnidad"].Value = cmbUnidad.SelectedValue.ToString(); sqlDAPromedios.SelectCommand.Parameters["@Todos"].Value = true; sqlDAPromedios.SelectCommand.Parameters["@IdDiam"].Value = cmbIdDiam.SelectedValue.ToString(); sqlDAPromedios.Fill(dsPromedios1, "Promedios"); // Establece el valor actual de parameter1 en el subinforme en 10 float res = float.Parse(dsConcreto1.Tables["Muestras"].Rows[buscaBtn1.RegistroSeleccionado][1].ToString()) * float.Parse(dsUnidad1.Tables["unidad"].Rows[cmbUnidad.SelectedIndex][2].ToString()); string Pdia = "3 días"; string Sdia = "7 días"; switch (int.Parse(cmbTipo.SelectedValue.ToString())) { case 1: case 2: Pdia = "3 días"; Sdia = "7 días"; break; case 6: case 11: Pdia = "1 día"; Sdia = "3 días"; break; case 7: case 12: Pdia = " "; Sdia = "1 día"; break; case 8: case 13: Pdia = " "; Sdia = " "; break; default: Pdia = "3 días"; Sdia = "7 días"; break; } //Una forma mas facil de pasar un parametro a un reporte de crystal cryRepPromedios1.SetParameterValue("@Equi", dsUnidad1.Tables["unidad"].Rows[cmbUnidad.SelectedIndex][2].ToString()); cryRepPromedios1.SetParameterValue("@Ubic", dsBuscaObra1.Tables[0].Rows[cmbIdObra.SelectedIndex][1].ToString()); cryRepPromedios1.SetParameterValue("@Diam", cmbIdDiam.SelectedValue.ToString()); cryRepPromedios1.SetParameterValue("@Pdia", Pdia); cryRepPromedios1.SetParameterValue("@Sdia", Sdia); //cryRepPromedios1.SetParameterValue("@Lab", chbLab.Checked); crvRepPromedios.Visible = true; crvRepPromedios.ReportSource = cryRepPromedios1; // crvRepPromedios.RefreshReport(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void PrintCollectionReceipt() { try { if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto) { MessageBox.Show("Sorry this option is not applicable for Auto-Print receipt.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); return; } if (!mboIsInTransaction) { MessageBox.Show("No active transaction is found! Please transact first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); return; } DialogResult loginresult = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.CloseTransaction); if (loginresult == DialogResult.None) { LogInWnd login = new LogInWnd(); login.AccessType = AccessTypes.CloseTransaction; login.Header = "Print Collection Receipt"; login.TerminalDetails = mclsTerminalDetails; login.ShowDialog(this); loginresult = login.Result; login.Close(); login.Dispose(); } if (loginresult == DialogResult.OK) { CRSReports.CR rpt = new CRSReports.CR(); AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset(); System.Data.DataRow drNew; /****************************sales transaction *****************************/ Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; Data.SalesTransactionDetails clsSalesTransactionDetails = clsSalesTransactions.Details(mclsSalesTransactionDetails.TransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID); Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); Data.ContactDetails clsContactDetails = clsContact.Details(clsSalesTransactionDetails.CustomerID); if (clsSalesTransactionDetails.isExist) { drNew = rptds.Transactions.NewRow(); drNew["TransactionID"] = clsSalesTransactionDetails.TransactionID; drNew["TransactionNo"] = clsSalesTransactionDetails.TransactionNo; drNew["ORNo"] = clsSalesTransactionDetails.ORNo; drNew["CustomerName"] = clsSalesTransactionDetails.CustomerName; drNew["CustomerAddress"] = clsContactDetails.Address; drNew["CustomerTerms"] = clsSalesTransactionDetails.Terms; drNew["CustomerModeOfterms"] = clsSalesTransactionDetails.ModeOfTerms; drNew["CustomerBusinessName"] = clsContactDetails.BusinessName; drNew["CustomerTelNo"] = clsContactDetails.TelephoneNo; drNew["CashierName"] = clsSalesTransactionDetails.CashierName; drNew["CreatedByName"] = clsSalesTransactionDetails.CreatedByName; drNew["AgentName"] = clsSalesTransactionDetails.AgentName; drNew["TerminalNo"] = clsSalesTransactionDetails.TerminalNo; drNew["TransactionDate"] = clsSalesTransactionDetails.TransactionDate; drNew["DateSuspended"] = clsSalesTransactionDetails.DateSuspended.ToString(); drNew["DateResumed"] = clsSalesTransactionDetails.DateResumed; drNew["TransactionStatus"] = clsSalesTransactionDetails.TransactionStatus; drNew["SubTotal"] = clsSalesTransactionDetails.SubTotal; drNew["ItemsDiscount"] = clsSalesTransactionDetails.ItemsDiscount; //drNew["SNRItemsDiscount"] = clsSalesTransactionDetails.SNRItemsDiscount; //drNew["PWDItemsDiscount"] = clsSalesTransactionDetails.PWDItemsDiscount; //drNew["OtherItemsDiscount"] = clsSalesTransactionDetails.OtherItemsDiscount; drNew["Discount"] = clsSalesTransactionDetails.Discount; drNew["VAT"] = clsSalesTransactionDetails.VAT; drNew["VATableAmount"] = clsSalesTransactionDetails.VATableAmount; //drNew["ZeroRatedSales"] = clsSalesTransactionDetails.ZeroRatedSales; drNew["LocalTax"] = clsSalesTransactionDetails.LocalTax; drNew["AmountPaid"] = clsSalesTransactionDetails.AmountPaid; drNew["CashPayment"] = clsSalesTransactionDetails.CashPayment; drNew["ChequePayment"] = clsSalesTransactionDetails.ChequePayment; drNew["CreditCardPayment"] = clsSalesTransactionDetails.CreditCardPayment; drNew["CreditPayment"] = clsSalesTransactionDetails.CreditPayment; drNew["DebitPayment"] = clsSalesTransactionDetails.DebitPayment; drNew["BalanceAmount"] = clsSalesTransactionDetails.BalanceAmount; drNew["ChangeAmount"] = clsSalesTransactionDetails.ChangeAmount; drNew["DateClosed"] = clsSalesTransactionDetails.DateClosed; drNew["PaymentType"] = clsSalesTransactionDetails.PaymentType.ToString("d"); drNew["Charge"] = clsSalesTransactionDetails.Charge; drNew["isConsignment"] = clsSalesTransactionDetails.isConsignment; drNew["CRNo"] = clsSalesTransactionDetails.CRNo.ToString().PadLeft(15, '0'); rptds.Transactions.Rows.Add(drNew); /****************************sales transaction items*****************************/ Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction); mConnection = clsSalesTransactionItems.Connection; mTransaction = clsSalesTransactionItems.Transaction; System.Data.DataTable dt = clsSalesTransactionItems.List(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.TransactionDate, "TransactionItemsID", SortOption.Ascending); foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.SalesTransactionItems.NewRow(); foreach (System.Data.DataColumn dc in rptds.SalesTransactionItems.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.SalesTransactionItems.Rows.Add(drNew); } } clsSalesTransactions.CommitAndDispose(); rpt.SetDataSource(rptds); CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField; CrystalDecisions.Shared.ParameterValues currentValues; CrystalDecisions.Shared.ParameterDiscreteValue discreteParam; paramField = rpt.DataDefinition.ParameterFields["CompanyName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.CompanyName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PrintedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.CashierName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PackedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.WaiterName; // grpItems.Text.Remove(0, 11); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.Address1 + ((!string.IsNullOrEmpty(CompanyDetails.Address2) ? Environment.NewLine + CompanyDetails.Address2 + ", " : " ")) + CompanyDetails.City + " " + CompanyDetails.Country + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " " : " ")) + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "FaxPhone #: " + CompanyDetails.FaxPhone + " " : " ")); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["BIRInfo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = "TIN : " + CompanyDetails.TIN + " VAT Reg." + Environment.NewLine + "BIR Acc #: " + CONFIG.AccreditationNo + " SN#: " + CONFIG.MachineSerialNo + Environment.NewLine + "Permit No: FP102014-064-0015149-00000"; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["TINNo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.CustomerDetails.TINNo; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["LTONo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.CustomerDetails.LTONo; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); //foreach (CrystalDecisions.CrystalReports.Engine.ReportObject objPic in rpt.Section1.ReportObjects) //{ // if (objPic.Name.ToUpper() == "PICLOGO1") // { // objPic = new Bitmap(Application.StartupPath + "/images/ReportLogo.jpg"); // } //} //CRViewer.Visible = true; //CRViewer.ReportSource = rpt; //CRViewer.Show(); try { DateTime logdate = DateTime.Now; string logsdir = System.Configuration.ConfigurationManager.AppSettings["logsdir"].ToString(); if (!Directory.Exists(logsdir + logdate.ToString("MMM"))) { Directory.CreateDirectory(logsdir + logdate.ToString("MMM")); } string logFile = logsdir + logdate.ToString("MMM") + "/CR_" + clsSalesTransactionDetails.TransactionNo + logdate.ToString("yyyyMMddhhmmss") + ".doc"; rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile); } catch { } if (isPrinterOnline(mclsTerminalDetails.SalesInvoicePrinterName)) { rpt.PrintOptions.PrinterName = mclsTerminalDetails.SalesInvoicePrinterName; rpt.PrintToPrinter(1, false, 0, 0); } else { clsEvent.AddEventLn("will not print delivery receipt. printer is offline.", true, mclsSysConfigDetails.WillWriteSystemLog); } rpt.Close(); rpt.Dispose(); } } catch (Exception ex) { InsertErrorLogToFile(ex); } }
public void PrintOfficialReceipt() { try { CRSReports.OR rpt = new CRSReports.OR(); AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset(); System.Data.DataRow drNew; /****************************report logo *****************************/ try { System.IO.FileStream fs = new System.IO.FileStream(Application.StartupPath + "/images/ReportLogo.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.FileInfo fi = new System.IO.FileInfo(Application.StartupPath + "/images/ReportLogo.jpg"); byte[] propimg = new byte[fi.Length]; fs.Read(propimg, 0, Convert.ToInt32(fs.Length)); fs.Close(); drNew = rptds.CompanyLogo.NewRow(); drNew["Picture"] = propimg; rptds.CompanyLogo.Rows.Add(drNew); } catch { } /****************************sales transaction *****************************/ Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; Data.SalesTransactionDetails clsSalesTransactionDetails = clsSalesTransactions.Details(mclsSalesTransactionDetails.TransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID); Data.Contacts clsContact = new Data.Contacts(mConnection, mTransaction); mConnection = clsContact.Connection; mTransaction = clsContact.Transaction; Data.ContactDetails clsContactDetails = clsContact.Details(clsSalesTransactionDetails.CustomerID); if (clsSalesTransactionDetails.isExist) { /****************************sales transaction details*****************************/ drNew = rptds.Transactions.NewRow(); drNew["TransactionID"] = clsSalesTransactionDetails.TransactionID; drNew["TransactionNo"] = clsSalesTransactionDetails.TransactionNo; drNew["ORNo"] = clsSalesTransactionDetails.ORNo; drNew["CustomerName"] = clsSalesTransactionDetails.CustomerName; drNew["CustomerAddress"] = clsContactDetails.Address; drNew["CustomerTerms"] = clsSalesTransactionDetails.Terms; drNew["CustomerModeOfterms"] = clsSalesTransactionDetails.ModeOfTerms; drNew["CustomerBusinessName"] = clsContactDetails.BusinessName; drNew["CustomerTelNo"] = clsContactDetails.TelephoneNo; drNew["CashierName"] = clsSalesTransactionDetails.CashierName; drNew["CreatedByName"] = clsSalesTransactionDetails.CreatedByName; drNew["AgentName"] = clsSalesTransactionDetails.AgentName; drNew["TerminalNo"] = clsSalesTransactionDetails.TerminalNo; drNew["TransactionDate"] = clsSalesTransactionDetails.TransactionDate; drNew["DateSuspended"] = clsSalesTransactionDetails.DateSuspended.ToString(); drNew["DateResumed"] = clsSalesTransactionDetails.DateResumed; drNew["TransactionStatus"] = clsSalesTransactionDetails.TransactionStatus; drNew["SubTotal"] = clsSalesTransactionDetails.SubTotal; drNew["ItemsDiscount"] = clsSalesTransactionDetails.ItemsDiscount; //drNew["SNRItemsDiscount"] = clsSalesTransactionDetails.SNRItemsDiscount; //drNew["PWDItemsDiscount"] = clsSalesTransactionDetails.PWDItemsDiscount; //drNew["OtherItemsDiscount"] = clsSalesTransactionDetails.OtherItemsDiscount; drNew["Discount"] = clsSalesTransactionDetails.Discount; drNew["VAT"] = clsSalesTransactionDetails.VAT; drNew["VATableAmount"] = clsSalesTransactionDetails.VATableAmount; //drNew["ZeroRatedSales"] = clsSalesTransactionDetails.ZeroRatedSales; drNew["LocalTax"] = clsSalesTransactionDetails.LocalTax; drNew["AmountPaid"] = clsSalesTransactionDetails.AmountPaid; drNew["CashPayment"] = clsSalesTransactionDetails.CashPayment; drNew["ChequePayment"] = clsSalesTransactionDetails.ChequePayment; drNew["CreditCardPayment"] = clsSalesTransactionDetails.CreditCardPayment; drNew["CreditPayment"] = clsSalesTransactionDetails.CreditPayment; drNew["DebitPayment"] = clsSalesTransactionDetails.DebitPayment; drNew["BalanceAmount"] = clsSalesTransactionDetails.BalanceAmount; drNew["ChangeAmount"] = clsSalesTransactionDetails.ChangeAmount; drNew["DateClosed"] = clsSalesTransactionDetails.DateClosed; drNew["PaymentType"] = clsSalesTransactionDetails.PaymentType.ToString("d"); drNew["Charge"] = clsSalesTransactionDetails.Charge; drNew["isConsignment"] = clsSalesTransactionDetails.isConsignment; drNew["CRNo"] = clsSalesTransactionDetails.CRNo; rptds.Transactions.Rows.Add(drNew); /****************************sales transaction items*****************************/ Data.SalesTransactionItems clsSalesTransactionItems = new Data.SalesTransactionItems(mConnection, mTransaction); mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction; System.Data.DataTable dt = clsSalesTransactionItems.List(clsSalesTransactionDetails.TransactionID, clsSalesTransactionDetails.TransactionDate, "TransactionItemsID", SortOption.Ascending); foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.SalesTransactionItems.NewRow(); foreach (System.Data.DataColumn dc in rptds.SalesTransactionItems.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.SalesTransactionItems.Rows.Add(drNew); } } clsSalesTransactions.CommitAndDispose(); rpt.SetDataSource(rptds); CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField; CrystalDecisions.Shared.ParameterValues currentValues; CrystalDecisions.Shared.ParameterDiscreteValue discreteParam; paramField = rpt.DataDefinition.ParameterFields["CompanyName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.CompanyName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PrintedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.CashierName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PackedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = mclsSalesTransactionDetails.WaiterName; // grpItems.Text.Remove(0, 11); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.Address1 + ((!string.IsNullOrEmpty(CompanyDetails.Address2) ? Environment.NewLine + CompanyDetails.Address2 + ", " : " ")) + CompanyDetails.City + " " + CompanyDetails.Country + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " " : " ")) + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "FaxPhone #: " + CompanyDetails.FaxPhone + " " : " ")); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["BIRInfo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = "TIN : " + CompanyDetails.TIN + " VAT Reg." + Environment.NewLine + "BIR Acc #: " + CONFIG.AccreditationNo + " SN#: " + CONFIG.MachineSerialNo + Environment.NewLine + "Permit No: FP102014-064-0015149-00000"; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); //foreach (CrystalDecisions.CrystalReports.Engine.ReportObject objPic in rpt.Section1.ReportObjects) //{ // if (objPic.Name.ToUpper() == "PICLOGO1") // { // objPic = new Bitmap(Application.StartupPath + "/images/ReportLogo.jpg"); // } //} //CRViewer.Visible = true; //CRViewer.ReportSource = rpt; //CRViewer.Show(); try { DateTime logdate = DateTime.Now; string logsdir = System.Configuration.ConfigurationManager.AppSettings["logsdir"].ToString(); if (!Directory.Exists(logsdir + logdate.ToString("MMM"))) { Directory.CreateDirectory(logsdir + logdate.ToString("MMM")); } string logFile = logsdir + logdate.ToString("MMM") + "/OR_" + clsSalesTransactionDetails.TransactionNo + logdate.ToString("yyyyMMddhhmmss") + ".doc"; rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile); } catch { } if (isPrinterOnline(mclsTerminalDetails.SalesInvoicePrinterName)) { rpt.PrintOptions.PrinterName = mclsTerminalDetails.SalesInvoicePrinterName; rpt.PrintToPrinter(1, false, 0, 0); } else { clsEvent.AddEventLn("will not print sales invoice. printer is offline.", true, mclsSysConfigDetails.WillWriteSystemLog); } rpt.Close(); rpt.Dispose(); } catch (Exception ex) { InsertErrorLogToFile(ex); MessageBox.Show("Sorry an error was encountered during printing, please reprint again." + Environment.NewLine + "Details: " + ex.Message, "RetailPlus"); } }
private void AsignarParametros(double p) { CrystalDecisions.Shared.ParameterValues myVals = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue myDiscrete = new CrystalDecisions.Shared.ParameterDiscreteValue(); myDiscrete.Value = NumALet.ToCardinal(Convert.ToDecimal(p)); myVals.Add(myDiscrete); facturaRpt.DataDefinition.ParameterFields[0].ApplyCurrentValues(myVals); }
private void btnVistaPrevia_Click(object sender, System.EventArgs e) { cryRepSemNormalAR1.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape; cryRepSemNormalAR1.SetDataSource(dsRepSemNormal1); try { CrystalDecisions.Shared.ParameterValues pvCollection = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue pdvMezcla = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvMezcla.Value = cmbMezcla.Text; CrystalDecisions.Shared.ParameterDiscreteValue pdvFirma1 = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterDiscreteValue pdvCargo1 = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvFirma1.Value = dsFirmas1.Tables["Firmas"].Rows[0][1].ToString(); pdvCargo1.Value = dsFirmas1.Tables["Firmas"].Rows[0][2].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvFirma2 = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterDiscreteValue pdvCargo2 = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvFirma2.Value = dsFirmas1.Tables["Firmas"].Rows[1][1].ToString(); pdvCargo2.Value = dsFirmas1.Tables["Firmas"].Rows[1][2].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvFirma3 = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterDiscreteValue pdvCargo3 = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvFirma3.Value = dsFirmas1.Tables["Firmas"].Rows[2][1].ToString(); pdvCargo3.Value = dsFirmas1.Tables["Firmas"].Rows[2][2].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvFirma4 = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterDiscreteValue pdvCargo4 = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvFirma4.Value = dsFirmas1.Tables["Firmas"].Rows[3][1].ToString(); pdvCargo4.Value = dsFirmas1.Tables["Firmas"].Rows[3][2].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvLogo = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvLogo.Value = chbLogo.Checked; pvCollection.Clear(); pvCollection.Add(pdvMezcla); cryRepSemNormalAR1.DataDefinition.ParameterFields["@Mezcla"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvFirma1); cryRepSemNormalAR1.DataDefinition.ParameterFields["@F1"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvCargo1); cryRepSemNormalAR1.DataDefinition.ParameterFields["@C1"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvFirma2); cryRepSemNormalAR1.DataDefinition.ParameterFields["@F2"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvCargo2); cryRepSemNormalAR1.DataDefinition.ParameterFields["@C2"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvFirma3); cryRepSemNormalAR1.DataDefinition.ParameterFields["@F3"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvCargo3); cryRepSemNormalAR1.DataDefinition.ParameterFields["@C3"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvFirma4); cryRepSemNormalAR1.DataDefinition.ParameterFields["@F4"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvCargo4); cryRepSemNormalAR1.DataDefinition.ParameterFields["@C4"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvLogo); cryRepSemNormalAR1.DataDefinition.ParameterFields["@Ruta"].ApplyCurrentValues(pvCollection); } catch (Exception ex1) { MessageBox.Show("parametro" + ex1.Message); } try { crvRepSemNormal.Visible = true; dsRepSemNormal1.Clear(); sqlDARepSemNormalLogo.SelectCommand.Parameters["@IdObra"].Value = cmbIdObra.SelectedValue.ToString(); sqlDARepSemNormalLogo.SelectCommand.Parameters["@IdConcretera"].Value = (cmbConcretera.SelectedValue.ToString() == "Todas" ? "%" : cmbConcretera.SelectedValue.ToString()); sqlDARepSemNormalLogo.SelectCommand.Parameters["@IdPlanta"].Value = (cmbPlanta.SelectedIndex == 0 ? "%" : cmbPlanta.SelectedValue.ToString()); sqlDARepSemNormalLogo.SelectCommand.Parameters["@FechaIni"].Value = dtpIni.Text; sqlDARepSemNormalLogo.SelectCommand.Parameters["@FechaFin"].Value = dtpFin.Text; sqlDARepSemNormalLogo.SelectCommand.Parameters["@IdReporte"].Value = 4; sqlDARepSemNormalLogo.SelectCommand.Parameters["@IdUnidad"].Value = cmbUnidad.SelectedValue.ToString(); sqlDARepSemNormalLogo.SelectCommand.Parameters["@Mezcla"].Value = cmbMezcla.SelectedValue.ToString(); sqlDARepSemNormalLogo.SelectCommand.Parameters["@Nulos"].Value = chbImprime.Checked; sqlDARepSemNormalLogo.SelectCommand.Parameters["@Secuencia"].Value = chbRevisa.Checked; sqlDARepSemNormalLogo.Fill(dsRepSemNormal1, "RepSemNormal"); int cuantos = dsRepSemNormal1.Tables["RepSemNormal"].Rows.Count; sqlDANorma.SelectCommand.Parameters["@IdNorma"].Value = cmbMezcla.SelectedValue; sqlDANorma.Fill(dsRepSemNormal1, "Normas"); cryRepSemNormalAR1.SetParameterValue("@F5", dsFirmas1.Tables["Firmas"].Rows[4][1].ToString()); cryRepSemNormalAR1.SetParameterValue("@C5", dsFirmas1.Tables["Firmas"].Rows[4][2].ToString()); cryRepSemNormalAR1.SetParameterValue("@Leyenda", chbLeyenda.Checked); cryRepSemNormalAR1.SetParameterValue("@Duplicado", chbDuplicado.Checked); cryRepSemNormalAR1.SetParameterValue("@Lab", chbLab.Checked); crvRepSemNormal.ReportSource = cryRepSemNormalAR1; //crvRepSemNormal.RefreshReport(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void PrintSOA() { Cursor.Current = Cursors.WaitCursor; try { CRSReports.SOA rpt = new CRSReports.SOA(); AceSoft.RetailPlus.Client.ReportDataset rptds = new AceSoft.RetailPlus.Client.ReportDataset(); System.Data.DataRow drNew; /****************************report logo *****************************/ try { System.IO.FileStream fs = new System.IO.FileStream(Application.StartupPath + "/images/ReportLogo.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.FileInfo fi = new System.IO.FileInfo(Application.StartupPath + "/images/ReportLogo.jpg"); byte[] propimg = new byte[fi.Length]; fs.Read(propimg, 0, Convert.ToInt32(fs.Length)); fs.Close(); drNew = rptds.CompanyLogo.NewRow(); drNew["Picture"] = propimg; rptds.CompanyLogo.Rows.Add(drNew); } catch { } /****************************datatable*****************************/ Data.Contacts clsContacts = new Data.Contacts(); System.Data.DataTable dt = clsContacts.ListAsDataTable(ContactID: mclsCustomerDetails.ContactID); clsContacts.CommitAndDispose(); foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.Customer.NewRow(); foreach (System.Data.DataColumn dc in rptds.Customer.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.Customer.Rows.Add(drNew); } dt = (System.Data.DataTable) dgvItems.DataSource; foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.CustomerCredit.NewRow(); foreach (System.Data.DataColumn dc in rptds.CustomerCredit.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.CustomerCredit.Rows.Add(drNew); } rpt.SetDataSource(rptds); CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField; CrystalDecisions.Shared.ParameterValues currentValues; CrystalDecisions.Shared.ParameterDiscreteValue discreteParam; paramField = rpt.DataDefinition.ParameterFields["CompanyName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.CompanyName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PrintedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CashierName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PackedBy"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CashierName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.Address1 + ((!string.IsNullOrEmpty(CompanyDetails.Address2) ? Environment.NewLine + CompanyDetails.Address2 + ", " : " ")) + CompanyDetails.City + " " + CompanyDetails.Country + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " " : " ")) + ((!string.IsNullOrEmpty(CompanyDetails.OfficePhone) ? Environment.NewLine + "FaxPhone #: " + CompanyDetails.FaxPhone + " " : " ")); currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["BIRInfo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = ""; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); //foreach (CrystalDecisions.CrystalReports.Engine.ReportObject objPic in rpt.Section1.ReportObjects) //{ // if (objPic.Name.ToUpper() == "PICLOGO1") // { // objPic = new Bitmap(Application.StartupPath + "/images/ReportLogo.jpg"); // } //} //CRViewer.Visible = true; //CRViewer.ReportSource = rpt; //CRViewer.Show(); try { DateTime logdate = DateTime.Now; string logsdir = System.Configuration.ConfigurationManager.AppSettings["logsdir"].ToString(); if (!Directory.Exists(logsdir + logdate.ToString("MMM"))) { Directory.CreateDirectory(logsdir + logdate.ToString("MMM")); } string logFile = logsdir + logdate.ToString("MMM") + "/SOA_" + logdate.ToString("yyyyMMddhhmmss") + ".doc"; rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile); } catch { } if (isPrinterOnline(TerminalDetails.SalesInvoicePrinterName)) { rpt.PrintOptions.PrinterName = TerminalDetails.SalesInvoicePrinterName; rpt.PrintToPrinter(1, false, 0, 0); rpt.Close(); rpt.Dispose(); Cursor.Current = Cursors.Default; MessageBox.Show("Statement Of Account for " + mclsCustomerDetails.ContactName + " has been printed.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { rpt.Close(); rpt.Dispose(); Cursor.Current = Cursors.Default; MessageBox.Show("Sorry, will not print sales invoice. printer is offline.", "RetailPlus"); } } catch (Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Sorry an error was encountered during printing, please reprint again." + Environment.NewLine + "Details: " + ex.Message, "RetailPlus"); } }
private void ReporteSalidaSeleccionada_Load(object sender, EventArgs e) { string appPath2 = Path.GetDirectoryName(Application.ExecutablePath); ///create the connection string string connString = @"Data Source= " + appPath2 + @"\DBBIT.s3db ;Version=3;"; //create the database query string query = "SELECT * FROM Salidas where Numero = '" + numero + "'"; //create an OleDbDataAdapter to execute the query System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString); //create a command builder System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter); //create a DataTable to hold the query results DataTable dTable = new DataTable(); //fill the DataTable dAdapter.Fill(dTable); dAdapter.Update(dTable); DataRow Row = dTable.Rows[0]; System.Byte[] rdr = (System.Byte[])Row["Huella"]; Image imagen = ByteToImage(rdr); imagen.Save(appPath2 + @"\huella.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //-------------------------- CrystalReport8 objRpt = new CrystalReport8(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\DBBIT.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT * FROM Salidas where Numero = " + numero; //String Query1 = "Select * from SRDatosGenerales Where IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRTamanoTipo Where IDFormatoSillas = '"+idformatossillas+"'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable5"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; appPath = appPath + @"\huella.jpg"; DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }
protected static string PrintCreditBillWG(Data.ContactDetails clsGuarantorDetails, System.Data.DataTable dtCreditors, Data.CardTypeDetails clsCreditCardTypeInfo) { CreditBiller.CRSReports.BillingWGuarantor rpt = new CreditBiller.CRSReports.BillingWGuarantor(); CreditBiller.ReportDataset rptds = new CreditBiller.ReportDataset(); System.Data.DataRow drNew; foreach (System.Data.DataRow dr in dtCreditors.Rows) { drNew = rptds.CreditBillHeader.NewRow(); foreach (System.Data.DataColumn dc in rptds.CreditBillHeader.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.CreditBillHeader.Rows.Add(drNew); } rpt.SetDataSource(rptds); CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField; CrystalDecisions.Shared.ParameterValues currentValues; CrystalDecisions.Shared.ParameterDiscreteValue discreteParam; paramField = rpt.DataDefinition.ParameterFields["CompanyName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.CompanyNameWG; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["BillingDate"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsCreditCardTypeInfo.BillingDate; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PaymentDueDate"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsCreditCardTypeInfo.CreditCutOffDate; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.Address1 + Environment.NewLine + CompanyDetails.Address2 + ", " + CompanyDetails.City + " " + CompanyDetails.Country + Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " Fax #:" + CompanyDetails.FaxPhone + Environment.NewLine + "TIN : " + CompanyDetails.TIN + " VAT Reg."; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["ContactName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsGuarantorDetails.ContactName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["ContactCode"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsGuarantorDetails.ContactCode; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["ContactAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsGuarantorDetails.Address; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CreditPurcStartDateToProcess"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsCreditCardTypeInfo.CreditPurcStartDateToProcess; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CreditPurcEndDateToProcess"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsCreditCardTypeInfo.CreditPurcEndDateToProcess; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); string strRetValue = ""; try { string logsdir = System.Configuration.ConfigurationManager.AppSettings["billingdir"].ToString(); logsdir += logsdir.EndsWith("/") ? "" : "/"; if (!Directory.Exists(logsdir + "withg")) { Directory.CreateDirectory(logsdir + "withg"); } string logFile = logsdir + "withg/OR_" + clsGuarantorDetails.ContactID.ToString() + clsCreditCardTypeInfo.BillingDate.ToString("yyyyMMdd") + ".doc"; if (File.Exists(logFile)) { MoveCreditBillToNextFile(logFile, 1); } rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile); strRetValue = "OR_" + clsGuarantorDetails.ContactID.ToString() + clsCreditCardTypeInfo.BillingDate.ToString("yyyyMMdd") + ".doc"; } catch { } try { bool boCreditBillerWillPrintORs = false; if (System.Configuration.ConfigurationManager.AppSettings["CreditBillerWillPrintORs"] != null) boCreditBillerWillPrintORs = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["CreditBillerWillPrintORs"].ToString()); if (boCreditBillerWillPrintORs) { string strCreditBillerPrinterName = ""; if (System.Configuration.ConfigurationManager.AppSettings["CreditBillerPrinterName"] != null) strCreditBillerPrinterName = System.Configuration.ConfigurationManager.AppSettings["CreditBillerPrinterName"].ToString(); if (PrinterHelper.isPrinterOnline(strCreditBillerPrinterName)) { rpt.PrintOptions.PrinterName = strCreditBillerPrinterName; rpt.PrintToPrinter(1, false, 0, 0); } else { WriteProcessToMonitor("will not print sales invoice. '" + strCreditBillerPrinterName + "' printer is offline."); } } } catch { } rpt.Close(); rpt.Dispose(); return strRetValue; }
private void ReporteSillasR_Load(object sender, EventArgs e) { string appPath2 = Path.GetDirectoryName(Application.ExecutablePath); ///create the connection string string connString = @"Data Source= " + appPath2 + @"\DBESIL.s3db ;Version=3;"; //create the database query string query = "SELECT * FROM SRTamanoTipo where IDFormatoSillas = '" + idformatossillas + "'"; //create an OleDbDataAdapter to execute the query System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString); //create a command builder System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter); //create a DataTable to hold the query results DataTable dTable = new DataTable(); //fill the DataTable dAdapter.Fill(dTable); dAdapter.Update(dTable); DataRow Row = dTable.Rows[0]; System.Byte[] rdr = (System.Byte[])Row["Foto"]; Image imagen = ByteToImage(rdr); imagen.Save(appPath2 + @"\perfil.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //-------------------------- CrystalReport4 objRpt = new CrystalReport4(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\DBESIL.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT SRDatosGenerales.IDFormatoSillas as IDFormatoSillas, Fecha, FechadeNacimiento, Edad, Nombre, Genero, ClinicaAsociacionMedica, Direccion, Ciudad, Estado, Pais, Telefono, Fax, Email, TipoDiscapacidad, Estatura, Peso, Coronilla, Hombro, PiernaSuperior, PiernaInferior, Pecho, Cadera, SentarseSinAyuda, SoporteCabeza, SoporteCuerpo, Foto FROM SRDatosGenerales, SRTamanoTipo Where SRDatosGenerales.IDFormatoSillas = '" + idformatossillas + "' AND SRTamanoTipo.IDFormatoSillas = '" + idformatossillas + "'"; //String Query1 = "Select * from SRDatosGenerales Where IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRTamanoTipo Where IDFormatoSillas = '"+idformatossillas+"'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable3"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; appPath = appPath + @"\perfil.jpg"; DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }
protected static string PrintCreditBillLX(Data.BillingDetails clsBillingDetails) { Data.Billing clsBilling = new Data.Billing(mConnection, mTransaction); mConnection = clsBilling.Connection; mTransaction = clsBilling.Transaction; System.Data.DataTable dt = clsBilling.ListDetailsAsDataTable(clsBillingDetails.CreditBillHeaderID); clsBilling.CommitAndDispose(); CreditBiller.CRSReports.BillingLX rpt = new CreditBiller.CRSReports.BillingLX(); CreditBiller.ReportDataset rptds = new CreditBiller.ReportDataset(); System.Data.DataRow drNew; foreach (System.Data.DataRow dr in dt.Rows) { drNew = rptds.CreditBillDetail.NewRow(); foreach (System.Data.DataColumn dc in rptds.CreditBillDetail.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.CreditBillDetail.Rows.Add(drNew); } rpt.SetDataSource(rptds); CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition paramField; CrystalDecisions.Shared.ParameterValues currentValues; CrystalDecisions.Shared.ParameterDiscreteValue discreteParam; paramField = rpt.DataDefinition.ParameterFields["CompanyName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.CompanyNameNoG; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["BillingDate"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.BillingDate; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PaymentDueDate"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CreditPaymentDueDate; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CompanyAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = CompanyDetails.Address1 + Environment.NewLine + CompanyDetails.Address2 + ", " + CompanyDetails.City + " " + CompanyDetails.Country + Environment.NewLine + "Tel #: " + CompanyDetails.OfficePhone + " Fax #:" + CompanyDetails.FaxPhone + Environment.NewLine + "TIN : " + CompanyDetails.TIN + " VAT Reg."; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["ContactName"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CustomerDetails.ContactName; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["ContactCode"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CustomerDetails.ContactCode; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["ContactAddress"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CustomerDetails.Address; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CreditCardNo"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CustomerDetails.CreditDetails.CreditCardNo; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CreditLimit"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CrediLimit; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CurrentDueAmount"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CurrentDueAmount; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["MinimumAmountDue"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.MinimumAmountDue; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["PrevMoCurrentDueAmount"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.Prev1MoCurrentDueAmount + clsBillingDetails.Prev2MoCurrentDueAmount; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CreditPurcStartDateToProcess"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CreditPurcStartDateToProcess; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); paramField = rpt.DataDefinition.ParameterFields["CreditPurcEndDateToProcess"]; discreteParam = new CrystalDecisions.Shared.ParameterDiscreteValue(); discreteParam.Value = clsBillingDetails.CreditPurcEndDateToProcess; currentValues = new CrystalDecisions.Shared.ParameterValues(); currentValues.Add(discreteParam); paramField.ApplyCurrentValues(currentValues); string strRetValue = ""; try { string logsdir = System.Configuration.ConfigurationManager.AppSettings["billingdir"].ToString(); logsdir += logsdir.EndsWith("/") ? "" : "/"; if (!Directory.Exists(logsdir + "woutg")) { Directory.CreateDirectory(logsdir + "woutg"); } string logFile = logsdir + "woutg/OR_" + clsBillingDetails.ContactID.ToString() + clsBillingDetails.BillingDate.ToString("yyyyMMdd") + ".doc"; if (File.Exists(logFile)) { MoveCreditBillToNextFile(logFile, 1); } bool boPrintToPDF = false; if (System.Configuration.ConfigurationManager.AppSettings["PrintToPDF"] != null) boPrintToPDF = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["PrintToPDF"].ToString()); if (boPrintToPDF) rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, logFile.Replace(".doc", ".pdf")); rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, logFile); strRetValue = "OR_" + clsBillingDetails.ContactID.ToString() + clsBillingDetails.BillingDate.ToString("yyyyMMdd") + ".doc"; } catch { } try { bool boCreditBillerWillPrintORs = false; if (System.Configuration.ConfigurationManager.AppSettings["CreditBillerWillPrintORs"] != null) boCreditBillerWillPrintORs = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["CreditBillerWillPrintORs"].ToString()); if (boCreditBillerWillPrintORs) { string strCreditBillerPrinterName = ""; if (System.Configuration.ConfigurationManager.AppSettings["CreditBillerPrinterName"] != null) strCreditBillerPrinterName = System.Configuration.ConfigurationManager.AppSettings["CreditBillerPrinterName"].ToString(); System.Drawing.Printing.PrintDocument printDoc = new System.Drawing.Printing.PrintDocument(); int i; int rawKind = 0; for (i = 0; i < printDoc.PrinterSettings.PaperSizes.Count; i++) { if (printDoc.PrinterSettings.PaperSizes[i].PaperName == "RetailPlusLXHalfSize") { rawKind = (int)PrinterHelper.GetField(printDoc.PrinterSettings.PaperSizes[i], "kind"); break; } } if (PrinterHelper.isPrinterOnline(strCreditBillerPrinterName)) { rpt.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind; rpt.PrintOptions.PrinterName = strCreditBillerPrinterName; rpt.PrintToPrinter(1, false, 0, 0); } else { WriteProcessToMonitor("will not print sales invoice. '" + strCreditBillerPrinterName + "' printer is offline."); } } } catch { } rpt.Close(); rpt.Dispose(); return strRetValue; }
private Boolean GenerateSchedReport() { Boolean res = false; res = _ValidateReportFields(); if (!res) { return(false); } try { frmPrintReport frm = new frmPrintReport(); CrystalDecisions.CrystalReports.Engine.ReportDocument objReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); CrystalDecisions.Shared.TableLogOnInfos crtableLogoninfos = new CrystalDecisions.Shared.TableLogOnInfos(); CrystalDecisions.Shared.TableLogOnInfo ConInfo = new CrystalDecisions.Shared.TableLogOnInfo(); CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo(); CrystalDecisions.CrystalReports.Engine.Tables CrTables; CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions crParameterFieldDefinitions; CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition crParameterFieldDefinition; CrystalDecisions.Shared.ParameterValues crParameterValues = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); objReport.Load(ClsConfig.PrintMonthlySchedule); //tbPartCode.Text, Convert.ToInt32(cboDeliverySchedMonth.SelectedValue.ToString()) // , Convert.ToInt32(cboDeliverySchedYear.SelectedItem.ToString()) crParameterDiscreteValue.Value = cboDeliverySchedMonth.SelectedValue.ToString(); crParameterFieldDefinitions = objReport.DataDefinition.ParameterFields; crParameterFieldDefinition = crParameterFieldDefinitions["@month"]; crParameterValues = crParameterFieldDefinition.CurrentValues; crParameterValues.Clear(); crParameterValues.Add(crParameterDiscreteValue); crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); crParameterDiscreteValue.Value = cboDeliverySchedYear.SelectedItem.ToString(); crParameterFieldDefinitions = objReport.DataDefinition.ParameterFields; crParameterFieldDefinition = crParameterFieldDefinitions["@year"]; crParameterValues = crParameterFieldDefinition.CurrentValues; crParameterValues.Clear(); crParameterValues.Add(crParameterDiscreteValue); crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); crParameterDiscreteValue.Value = cboCustomer.SelectedValue.ToString(); crParameterFieldDefinitions = objReport.DataDefinition.ParameterFields; crParameterFieldDefinition = crParameterFieldDefinitions["@Cus_ID"]; crParameterValues = crParameterFieldDefinition.CurrentValues; crParameterValues.Clear(); crParameterValues.Add(crParameterDiscreteValue); crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); string sUserID = ClsConfig.User; string sPassword = ClsConfig.Password; string sServerName = ClsConfig.Server; string sDatabaseName = ClsConfig.Database; crConnectionInfo.ServerName = sServerName; crConnectionInfo.DatabaseName = sDatabaseName; //crConnectionInfo.IntegratedSecurity = true; crConnectionInfo.UserID = sUserID; crConnectionInfo.Password = sPassword; CrTables = objReport.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { ConInfo = CrTable.LogOnInfo; ConInfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(ConInfo); } frm.crystalReportViewer1.ReportSource = objReport; frm.crystalReportViewer1.Zoom(100); frm.crystalReportViewer1.Refresh(); } catch { MessageBox.Show("Report File Does Not Exists!"); } return(true); }
private void ReporteSillasR_Load(object sender, EventArgs e) { string appPath2 = Path.GetDirectoryName(Application.ExecutablePath); ///create the connection string string connString = @"Data Source= " + appPath2 + @"\DBESIL.s3db ;Version=3;"; //create the database query string query = "SELECT * FROM SRTamanoTipo where IDFormatoSillas = '"+idformatossillas+"'"; //create an OleDbDataAdapter to execute the query System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString); //create a command builder System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter); //create a DataTable to hold the query results DataTable dTable = new DataTable(); //fill the DataTable dAdapter.Fill(dTable); dAdapter.Update(dTable); DataRow Row = dTable.Rows[0]; System.Byte[] rdr = (System.Byte[])Row["Foto"]; Image imagen = ByteToImage(rdr); imagen.Save(appPath2 + @"\perfil.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //-------------------------- CrystalReport4 objRpt = new CrystalReport4(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\DBESIL.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT SRDatosGenerales.IDFormatoSillas as IDFormatoSillas, Fecha, FechadeNacimiento, Edad, Nombre, Genero, ClinicaAsociacionMedica, Direccion, Ciudad, Estado, Pais, Telefono, Fax, Email, TipoDiscapacidad, Estatura, Peso, Coronilla, Hombro, PiernaSuperior, PiernaInferior, Pecho, Cadera, SentarseSinAyuda, SoporteCabeza, SoporteCuerpo, Foto FROM SRDatosGenerales, SRTamanoTipo Where SRDatosGenerales.IDFormatoSillas = '" + idformatossillas + "' AND SRTamanoTipo.IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRDatosGenerales Where IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRTamanoTipo Where IDFormatoSillas = '"+idformatossillas+"'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable3"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; appPath = appPath + @"\perfil.jpg"; DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }
private void btnVistaPrevia_Click(object sender, System.EventArgs e) { int resi = 0; string grado = " "; string gradot = " "; char cGrado; gradot = cmbGrado.SelectedValue.ToString().Trim(); int Longitud = gradot.Length; grado = ""; for (int i = 0; i < Longitud; i++) { cGrado = System.Convert.ToChar(gradot.Substring(i, 1)); if (char.IsNumber(cGrado)) { grado = grado + System.Convert.ToString(cGrado); } } grado = grado + " f*p "; crvRepAnalisis.Visible = true; cryRepAnalBlockC1.SetDataSource(dsAnalBlock1); try { CrystalDecisions.Shared.ParameterValues pvCollection = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue pdvRes = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvRes.Value = float.Parse(grado.Substring(0, 3)) * float.Parse(dsUnidad1.Tables["unidad"].Rows[cmbUnidad.SelectedIndex][2].ToString()); CrystalDecisions.Shared.ParameterDiscreteValue pdvTip = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvTip.Value = cmbTipo.SelectedValue.ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvLab = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvLab.Value = cmbNoEco.Text; CrystalDecisions.Shared.ParameterDiscreteValue pdvCra = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvCra.Value = dsBuscaObra1.Tables["Obra"].Rows[cmbIdObra.SelectedIndex][3].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvDir = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvDir.Value = dsBuscaObra1.Tables["Obra"].Rows[cmbIdObra.SelectedIndex][1].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvObr = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvObr.Value = txtIdobra.Text; CrystalDecisions.Shared.ParameterDiscreteValue pdvZon = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvZon.Value = dsBuscaObra1.Tables["Obra"].Rows[cmbIdObra.SelectedIndex][4].ToString(); CrystalDecisions.Shared.ParameterDiscreteValue pdvLoc = new CrystalDecisions.Shared.ParameterDiscreteValue(); pdvLoc.Value = dsBuscaObra1.Tables["Obra"].Rows[cmbIdObra.SelectedIndex][5].ToString(); pvCollection.Clear(); pvCollection.Add(pdvRes); cryRepAnalBlockC1.DataDefinition.ParameterFields["@Res"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvTip); cryRepAnalBlockC1.DataDefinition.ParameterFields["@Tip"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvLab); cryRepAnalBlockC1.DataDefinition.ParameterFields["@Lab"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvCra); cryRepAnalBlockC1.DataDefinition.ParameterFields["@Cra"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvDir); cryRepAnalBlockC1.DataDefinition.ParameterFields["@Dir"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvObr); cryRepAnalBlockC1.DataDefinition.ParameterFields["@Obr"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvZon); cryRepAnalBlockC1.DataDefinition.ParameterFields["@Zon"].ApplyCurrentValues(pvCollection); pvCollection.Clear(); pvCollection.Add(pdvLoc); cryRepAnalBlockC1.DataDefinition.ParameterFields["@Loc"].ApplyCurrentValues(pvCollection); } catch (Exception ex1) { MessageBox.Show("parametro" + ex1.Message); } dsAnalBlock1.Clear(); sqlDAAnalisis.SelectCommand.Parameters["@IdObra"].Value = (cmbIdObra.SelectedValue.ToString() == "Todas" ? "%" : txtIdobra.Text); sqlDAAnalisis.SelectCommand.Parameters["@FechaIni"].Value = dtpIni.Text; sqlDAAnalisis.SelectCommand.Parameters["@FechaFin"].Value = dtpFin.Text; sqlDAAnalisis.SelectCommand.Parameters["@Tipo"].Value = cmbTipo.SelectedValue.ToString(); sqlDAAnalisis.SelectCommand.Parameters["@Largo"].Value = txtLargo.Text; sqlDAAnalisis.SelectCommand.Parameters["@Ancho"].Value = txtAncho.Text; sqlDAAnalisis.SelectCommand.Parameters["@Peralte"].Value = txtPeralte.Text; sqlDAAnalisis.SelectCommand.Parameters["@IdUnidad"].Value = 1; sqlDAAnalisis.SelectCommand.Parameters["@NoEco"].Value = cmbNoEco.SelectedValue.ToString(); sqlDAAnalisis.SelectCommand.Parameters["@Datos"].Value = 3; sqlDAAnalisis.SelectCommand.Parameters["@Grado"].Value = cmbGrado.SelectedValue.ToString(); //grado; sqlDAAnalisis.SelectCommand.Parameters["@Como"].Value = cmbComo.SelectedValue.ToString(); sqlDAAnalisis.SelectCommand.Parameters["@TMuestra"].Value = true; sqlDAAnalisis.SelectCommand.Parameters["@Prove"].Value = (cmbProve.SelectedValue.ToString() == "Todos" ? "%" : cmbProve.SelectedValue); sqlDAAnalisis.Fill(dsAnalBlock1, "GraficaFinal"); sqlDAAnalisis.SelectCommand.Parameters["@Datos"].Value = 1; sqlDAAnalisis.Fill(dsAnalBlock1, "Analisis"); sqlDAAnalisis.SelectCommand.Parameters["@Datos"].Value = 2; sqlDAAnalisis.Fill(dsAnalBlock1, "Grafica1"); sqlDAAnalisis.SelectCommand.Parameters["@TMuestra"].Value = false; sqlDAAnalisis.SelectCommand.Parameters["@IdUnidad"].Value = cmbUnidad.SelectedValue.ToString(); sqlDAAnalisis.SelectCommand.Parameters["@Datos"].Value = 1; sqlDAAnalisis.Fill(dsAnalBlock1, "Analisis1"); sqlDAAnalisis.SelectCommand.Parameters["@Datos"].Value = 2; sqlDAAnalisis.Fill(dsAnalBlock1, "Grafica11"); sqlDAAnalisis.SelectCommand.Parameters["@Datos"].Value = 3; sqlDAAnalisis.Fill(dsAnalBlock1, "GraficaFinal1"); int cuantos = dsAnalBlock1.GraficaFinal.Rows.Count; cuantos = dsAnalBlock1.Grafica1.Rows.Count; cuantos = dsAnalBlock1.Analisis.Rows.Count; double[] gaus; gaus = new double[24]; double[] ee; ee = new double[24]; double[] nuevoee; nuevoee = new double[24]; double moda = 0; int indice = 1; for (int i = 1; i <= 23; i++) { nuevoee[i] = 0; ee[i] = double.Parse(dsAnalBlock1.Tables["GraficaFinal"].Rows[0][i].ToString()); if (moda < ee[i]) { indice = i; moda = ee[i]; } } indice = 12; for (int i = 1; i <= 23; i++) { if (1 <= (i - (12 - indice)) && (i - (12 - indice)) <= 23) { nuevoee[(i - (12 - indice))] = gaus[i] * (moda + 2); } } float res = float.Parse(grado.ToString().Substring(0, 3).Trim()) * float.Parse(dsUnidad1.Tables["unidad"].Rows[cmbUnidad.SelectedIndex][2].ToString()); sqlDATitulo.SelectCommand.Parameters["@ResistenciaKg"].Value = res.ToString(); sqlDATitulo.SelectCommand.Parameters["@IdUnidad"].Value = cmbUnidad.SelectedValue.ToString(); sqlDATitulo.SelectCommand.Parameters["@Hoja"].Value = int.Parse(dsAnalBlock1.Tables["GraficaFinal"].Rows[0][24].ToString()); sqlDATitulo.SelectCommand.Parameters["@Incre"].Value = 0.15; sqlDATitulo.Fill(dsAnalBlock1, "titulo"); cuantos = dsAnalBlock1.Analisis1.Rows.Count; int Lineas = dsAnalBlock1.GraficaFinal.Rows.Count; double res1 = 0; double res2 = 0; for (int i = 0; i < cuantos; i++) { if (!string.IsNullOrEmpty(dsAnalBlock1.Tables["Analisis1"].Rows[i]["ee1"].ToString())) { res2 = float.Parse(dsAnalBlock1.Tables["Analisis1"].Rows[i]["ee1"].ToString()); res1 = (res2 > res1 ? res2 : res1); } } //res1 = Math.Truncate((res1 / cuantos) * 10) / 10; sqlDATitulo.SelectCommand.Parameters["@ResistenciaKg"].Value = res1.ToString(); sqlDATitulo.SelectCommand.Parameters["@IdUnidad"].Value = 1; sqlDATitulo.SelectCommand.Parameters["@Hoja"].Value = int.Parse(dsAnalBlock1.Tables["GraficaFinal"].Rows[0][24].ToString()); sqlDATitulo.SelectCommand.Parameters["@Incre"].Value = 0.1; sqlDATitulo.Fill(dsAnalBlock1, "titulo1"); memGraphics.CreateDoubleBuffer(this.CreateGraphics(), this.ClientRectangle.Width, this.ClientRectangle.Height); myPane = new GraphPane(new Rectangle(10, 10, 10, 10), "", "Edad en días", "Frecuencia"); SetSize(); CurveItem curve; double incdec = 0.1; for (int j = 0; j < Lineas; j++) { for (int i = 0; i <= 21; i++) { nuevoee[i] = double.Parse(dsAnalBlock1.Tables["GraficaFinal"].Rows[j][i + 1].ToString()); ee[i] = res * (incdec * i); } if (j == 0) { curve = myPane.AddCurve("Reducida", ee, nuevoee, Color.DarkSeaGreen, SymbolType.Square); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.DarkSeaGreen); } if (j == 1) { curve = myPane.AddCurve("Completa", ee, nuevoee, Color.Cyan, SymbolType.Circle); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.Cyan); } if (j == 2) { curve = myPane.AddCurve(dsAnalBlock1.Tables["GraficaFinal"].Rows[j][0].ToString(), ee, nuevoee, Color.DarkSlateBlue, SymbolType.Diamond); curve.Line.Width = 3.5F; curve.Symbol.Fill = new Fill(Color.DarkSlateBlue); } if (j == 3) { curve = myPane.AddCurve(dsAnalBlock1.Tables["GraficaFinal"].Rows[j][0].ToString(), ee, nuevoee, Color.Brown, SymbolType.TriangleDown); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.Brown); } if (j == 4) { curve = myPane.AddCurve(dsAnalBlock1.Tables["GraficaFinal"].Rows[j][0].ToString(), ee, nuevoee, Color.DarkMagenta, SymbolType.Triangle); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.DarkMagenta); } } myPane.XAxis.IsMinorInsideTic = true; myPane.XAxis.TicSize = float.Parse((res * 0.05).ToString()); myPane.XAxis.IsShowGrid = true; myPane.XAxis.IsInsideTic = true; myPane.XAxis.ScaleFontSpec.Angle = 0; myPane.XAxis.NumDec = 0; myPane.XAxis.Step = float.Parse((res * 0.05).ToString()); myPane.XAxis.ScaleFontSpec.Size = 10; myPane.XAxis.Min = res * 0.1; //cambiar myPane.XAxis.Max = res * 22 * 0.1; myPane.XAxis.Type = AxisType.Linear; myPane.XAxis.StepAuto = true; // myPane1.XAxis.MinorStepAuto = true; myPane.XAxis.TitleFontSpec.Family = "Times New Roman"; myPane.XAxis.TitleFontSpec.Size = 12; myPane.XAxis.IsShowTitle = false; myPane.XAxis.ScaleFontSpec.FontColor = Color.Black; myPane.XAxis.IsMinorTic = true; myPane.YAxis.IsMinorInsideTic = true; myPane.XAxis.IsInsideTic = true; myPane.YAxis.IsShowGrid = true; myPane.YAxis.ScaleFontSpec.Angle = 90; myPane.YAxis.ScaleFontSpec.Size = 10; myPane.YAxis.Min = 0; myPane.YAxis.Max = Math.Round((moda / 10)) * 10; myPane.YAxis.TicSize = 10; myPane.YAxis.TitleFontSpec.Family = "Times New Roman"; myPane.YAxis.ScaleFontSpec.Family = "Times New Roman"; myPane.Legend.IsVisible = true; myPane.Legend.Location = LegendLoc.InsideTopRight; myPane.Legend.FontSpec.Size = 10; myPane.PaneFill = new Fill(Color.White, Color.White, 2F); myPane.AxisChange(this.CreateGraphics()); pictureBox2.Image = Image.FromHbitmap(myPane.Image.GetHbitmap()); pictureBox2.BorderStyle = BorderStyle.None; MemoryStream ms1 = new MemoryStream(); pictureBox2.Image.Save(ms1, System.Drawing.Imaging.ImageFormat.Bmp); byte[] arrImage1 = ms1.GetBuffer(); ms1.Close(); dsAnalBlock1.GraficaFinal.Rows[0]["Imagen1"] = arrImage1; Lineas = dsAnalBlock1.GraficaFinal1.Rows.Count; myPane = new GraphPane(new Rectangle(10, 10, 10, 10), "", "Edad en días", "Frecuencia"); SetSize(); incdec = 0.1; for (int j = 0; j < Lineas; j++) { for (int i = 0; i <= 21; i++) { nuevoee[i] = double.Parse(dsAnalBlock1.Tables["GraficaFinal1"].Rows[j][i + 1].ToString()); ee[i] = res * (incdec * i); } //if (j == 0) //{ // curve = myPane.AddCurve(dsAnalBlock1.Tables["GraficaFinal1"].Rows[j][0].ToString(), ee, nuevoee, Color.DarkSeaGreen, SymbolType.Square); // curve.Line.Width = 2.5F; // curve.Symbol.Fill = new Fill(Color.DarkSeaGreen); //} if (j == 1) { curve = myPane.AddCurve(dsAnalBlock1.Tables["GraficaFinal1"].Rows[j][0].ToString(), ee, nuevoee, Color.Cyan, SymbolType.Circle); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.Cyan); } if (j == 2) { curve = myPane.AddCurve(dsAnalBlock1.Tables["GraficaFinal1"].Rows[j][0].ToString(), ee, nuevoee, Color.DarkSlateBlue, SymbolType.Diamond); curve.Line.Width = 3.5F; curve.Symbol.Fill = new Fill(Color.DarkSlateBlue); } if (j == 3) { curve = myPane.AddCurve(dsAnalBlock1.Tables["GraficaFinal1"].Rows[j][0].ToString(), ee, nuevoee, Color.Brown, SymbolType.TriangleDown); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.Brown); } if (j == 4) { curve = myPane.AddCurve(dsAnalBlock1.Tables["GraficaFinal1"].Rows[j][0].ToString(), ee, nuevoee, Color.DarkMagenta, SymbolType.Triangle); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.DarkMagenta); } } myPane.XAxis.IsMinorInsideTic = true; myPane.XAxis.TicSize = float.Parse((res * 0.05).ToString()); myPane.XAxis.IsShowGrid = true; myPane.XAxis.IsInsideTic = true; myPane.XAxis.ScaleFontSpec.Angle = 0; myPane.XAxis.NumDec = 0; myPane.XAxis.Step = float.Parse((res * 0.05).ToString()); myPane.XAxis.ScaleFontSpec.Size = 10; myPane.XAxis.Min = res * 0.1; //cambiar myPane.XAxis.Max = res * 22 * 0.1; myPane.XAxis.Type = AxisType.Linear; myPane.XAxis.StepAuto = true; // myPane1.XAxis.MinorStepAuto = true; myPane.XAxis.TitleFontSpec.Family = "Times New Roman"; myPane.XAxis.TitleFontSpec.Size = 12; myPane.XAxis.IsShowTitle = false; myPane.XAxis.ScaleFontSpec.FontColor = Color.Black; myPane.XAxis.IsMinorTic = true; myPane.YAxis.IsMinorInsideTic = true; myPane.XAxis.IsInsideTic = true; myPane.YAxis.IsShowGrid = true; myPane.YAxis.ScaleFontSpec.Angle = 90; myPane.YAxis.ScaleFontSpec.Size = 10; myPane.YAxis.Min = 0; myPane.YAxis.Max = Math.Round((moda / 10)) * 10;; myPane.YAxis.TicSize = 10; myPane.YAxis.TitleFontSpec.Family = "Times New Roman"; myPane.YAxis.ScaleFontSpec.Family = "Times New Roman"; myPane.Legend.IsVisible = false; // myPane.Legend.Location = LegendLoc.InsideTopRight; myPane.Legend.FontSpec.Size = 10; myPane.PaneFill = new Fill(Color.White, Color.White, 2F); myPane.AxisChange(this.CreateGraphics()); pictureBox4.Image = Image.FromHbitmap(myPane.Image.GetHbitmap()); pictureBox4.BorderStyle = BorderStyle.None; MemoryStream ms2 = new MemoryStream(); pictureBox4.Image.Save(ms2, System.Drawing.Imaging.ImageFormat.Bmp); byte[] arrImage2 = ms2.GetBuffer(); arrImage2 = ms2.GetBuffer(); ms2.Close(); myPane.Image.Dispose(); pictureBox4.Image.Dispose(); dsAnalBlock1.GraficaFinal1.Rows[0]["Imagen2"] = arrImage2; Lineas = dsAnalBlock1.Grafica1.Rows.Count; incdec = 0.1; double[] eex; eex = new double[12]; double[] neey; neey = new double[12]; int hoja = int.Parse(dsAnalBlock1.Grafica1.Rows[0][0].ToString()); int hoaa = hoja; int ij = 0; double mayor = 0; myPane = new GraphPane(new Rectangle(10, 10, 10, 10), "", "", "Frecuencias"); SetSize(); for (int m = 0; m < dsAnalBlock1.Grafica1.Rows.Count; m++) { if (hoaa != int.Parse(dsAnalBlock1.Grafica1.Rows[m][0].ToString())) // && ij >= Lineas) { guardagrafica(res, hoaa, 1, mayor); myPane = new GraphPane(new Rectangle(10, 10, 10, 10), "", "", "Frecuencias"); SetSize(); ij = 0; hoaa = int.Parse(dsAnalBlock1.Grafica1.Rows[m][0].ToString()); mayor = 0; } for (int i = 0; i <= 11; i++) { neey[i] = double.Parse(dsAnalBlock1.Tables["Grafica1"].Rows[m][i + 2].ToString()); eex[i] = double.Parse(dsAnalBlock1.titulo.Rows[0][i + 2].ToString()); mayor = (neey[i] > mayor ? neey[i] : mayor); } if (ij == 0) { curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica1"].Rows[m][1].ToString(), eex, neey, Color.DarkSeaGreen, SymbolType.Square); curve.Symbol.Fill = new Fill(Color.DarkSeaGreen); curve.Line.Width = 2.5F; } if (ij == 1) { curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica1"].Rows[m][1].ToString(), eex, neey, Color.Cyan, SymbolType.Circle); curve.Symbol.Fill = new Fill(Color.Cyan); curve.Line.Width = 2.5F; } //if (ij == 2) //{ // curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica1"].Rows[m][1].ToString(), eex, neey, Color.DarkSlateBlue, SymbolType.Diamond); // curve.Line.Width = 3.5F; // curve.Symbol.Fill = new Fill(Color.DarkSlateBlue); //} //if (ij == 3) //{ // curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica1"].Rows[m][1].ToString(), eex, neey, Color.Brown, SymbolType.TriangleDown); // curve.Symbol.Fill = new Fill(Color.Brown); // curve.Line.Width = 2.5F; //} //if (ij == 4) //{ // curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica1"].Rows[m][1].ToString(), eex, neey, Color.DarkMagenta, SymbolType.TriangleDown); // curve.Symbol.Fill = new Fill(Color.DarkMagenta); // curve.Line.Width = 2.5F; //} ij++; } guardagrafica(res, hoaa, 1, mayor); Lineas = dsAnalBlock1.Grafica11.Rows.Count; hoja = int.Parse(dsAnalBlock1.Grafica11.Rows[0][0].ToString()); hoaa = hoja; ij = 0; myPane = new GraphPane(new Rectangle(10, 10, 10, 10), "", "", "Frecuencias"); SetSize(); for (int m = 0; m < dsAnalBlock1.Grafica11.Rows.Count; m++) { if (hoaa != int.Parse(dsAnalBlock1.Grafica11.Rows[m][0].ToString())) //&& ij >= Lineas) { guardagrafica(res, hoaa, 2, mayor); myPane = new GraphPane(new Rectangle(10, 10, 10, 10), "", "", "Frecuencias"); SetSize(); ij = 0; hoaa = int.Parse(dsAnalBlock1.Grafica11.Rows[m][0].ToString()); mayor = 0; } for (int i = 0; i <= 11; i++) { neey[i] = double.Parse(dsAnalBlock1.Tables["Grafica11"].Rows[m][i + 2].ToString()); eex[i] = double.Parse(dsAnalBlock1.titulo.Rows[0][i + 2].ToString()); mayor = (neey[i] > mayor ? neey[i] : mayor); } if (ij == 0) { curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica11"].Rows[m][1].ToString(), eex, neey, Color.DarkSeaGreen, SymbolType.Square); curve.Symbol.Fill = new Fill(Color.DarkSeaGreen); curve.Line.Width = 2.5F; } if (ij == 1) { curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica11"].Rows[m][1].ToString(), eex, neey, Color.Cyan, SymbolType.Circle); curve.Symbol.Fill = new Fill(Color.Cyan); curve.Line.Width = 2.5F; } //if (ij == 2) //{ // curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica11"].Rows[m][1].ToString(), eex, neey, Color.DarkSlateBlue, SymbolType.Diamond); // curve.Line.Width = 3.5F; // curve.Symbol.Fill = new Fill(Color.DarkSlateBlue); //} //if (ij == 3) //{ // curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica1"].Rows[m][1].ToString(), eex, neey, Color.Brown, SymbolType.TriangleDown); // curve.Symbol.Fill = new Fill(Color.Brown); // curve.Line.Width = 2.5F; //} //if (ij == 4) //{ // curve = myPane.AddCurve(dsAnalBlock1.Tables["Grafica1"].Rows[m][1].ToString(), eex, neey, Color.DarkMagenta, SymbolType.TriangleDown); // curve.Symbol.Fill = new Fill(Color.DarkMagenta); // curve.Line.Width = 2.5F; //} ij++; } guardagrafica(res, hoaa, 2, mayor); resi = System.Convert.ToInt32(Math.Floor(res)); // Establece el valor actual de parameter1 en el subinforme en 10 cryRepAnalBlockC1.SetParameterValue("@reskg", res.ToString(), "Gauss"); cryRepAnalBlockC1.SetParameterValue("@Unidad", cmbUnidad.Text); cryRepAnalBlockC1.SetParameterValue("@Unidad", cmbUnidad.Text, "Gauss"); cryRepAnalBlockC1.SetParameterValue("@Equi", dsUnidad1.Tables["unidad"].Rows[cmbUnidad.SelectedIndex][2].ToString()); cryRepAnalBlockC1.SetParameterValue("@Prueba", cmbPrueba.Text); cryRepAnalBlockC1.SetParameterValue("@Grado", cmbGrado.SelectedValue.ToString()); cryRepAnalBlockC1.SetParameterValue("@Indice", resi); cryRepAnalBlockC1.SetParameterValue("@Como", cmbComo.SelectedValue); cryRepAnalBlockC1.SetParameterValue("@Largo", txtLargo.Text); cryRepAnalBlockC1.SetParameterValue("@Ancho", txtAncho.Text); cryRepAnalBlockC1.SetParameterValue("@Peralte", txtPeralte.Text); cryRepAnalBlockC1.SetParameterValue("@Lab1", chbLab.Checked); cryRepAnalBlockC1.SetParameterValue("@Prove", cmbProve.SelectedValue.ToString()); crvRepAnalisis.ReportSource = cryRepAnalBlockC1; }
private void AsignarParametros(double p) { CrystalDecisions.Shared.ParameterValues myVals = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue myDiscrete = new CrystalDecisions.Shared.ParameterDiscreteValue(); myDiscrete.Value = NumALet.ToCardinal(Convert.ToDecimal(p)); myVals.Add(myDiscrete); facturaRpt.DataDefinition.ParameterFields[0].ApplyCurrentValues(myVals); facturaRpt.Subreports["resumen"].DataDefinition.FormulaFields["ImpTotTexto"].Text = "'" + NumALet.ToCardinal(Convert.ToDecimal(p)) + "'"; }
public void GenerateReport() { try { string filepart = @"file:\"; CrystalDecisions.CrystalReports.Engine.ReportDocument objReport1 = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); CrystalDecisions.Shared.TableLogOnInfos crtableLogoninfos = new CrystalDecisions.Shared.TableLogOnInfos(); CrystalDecisions.Shared.TableLogOnInfo ConInfo = new CrystalDecisions.Shared.TableLogOnInfo(); CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo(); CrystalDecisions.CrystalReports.Engine.Tables CrTables; CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions crParameterFieldDefinitions; CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition crParameterFieldDefinition; CrystalDecisions.Shared.ParameterValues crParameterValues = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace(filepart, "") + @"\PEZA_REPORTS\rpt_PEZA_8106_BoatNote.rpt")) { objReport1.Load(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace(filepart, "") + @"\PEZA_REPORTS\rpt_PEZA_8106_BoatNote.rpt"); } else { objReport1.Load(ClsConfig.PEZAReportPath_Trial + "rpt_PEZA_8106_BoatNote.rpt"); } crParameterDiscreteValue.Value = _formNo.ToString().Trim();//recDate.SelectedDate.Value; crParameterFieldDefinitions = objReport1.DataDefinition.ParameterFields; crParameterFieldDefinition = crParameterFieldDefinitions["@8106FormNo"]; crParameterValues = crParameterFieldDefinition.CurrentValues; crParameterValues.Clear(); crParameterValues.Add(crParameterDiscreteValue); crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); //objReport1.SetParameterValue("@8106FormNo", "14176560"); string sUserID = ClsConfig.ReportUser; string sPassword = ClsConfig.ReportPassword; string sServerName = ClsConfig.ReportServer; string sDatabaseName = ClsConfig.ReportDatabase_PEZA; crConnectionInfo.ServerName = sServerName; crConnectionInfo.DatabaseName = sDatabaseName; //crConnectionInfo.IntegratedSecurity = true; crConnectionInfo.UserID = sUserID; crConnectionInfo.Password = sPassword; CrTables = objReport1.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { ConInfo = CrTable.LogOnInfo; ConInfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(ConInfo); } reportViewer.ViewerCore.ReportSource = objReport1; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void ReporteSalidaSeleccionada_Load(object sender, EventArgs e) { string appPath2 = Path.GetDirectoryName(Application.ExecutablePath); ///create the connection string string connString = @"Data Source= " + appPath2 + @"\DBBIT.s3db ;Version=3;"; //create the database query string query = "SELECT * FROM Salidas where Numero = '" + numero + "'"; //create an OleDbDataAdapter to execute the query System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString); //create a command builder System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter); //create a DataTable to hold the query results DataTable dTable = new DataTable(); //fill the DataTable dAdapter.Fill(dTable); dAdapter.Update(dTable); DataRow Row = dTable.Rows[0]; System.Byte[] rdr = (System.Byte[])Row["Huella"]; Image imagen = ByteToImage(rdr); imagen.Save(appPath2 + @"\huella.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //-------------------------- CrystalReport8 objRpt = new CrystalReport8(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\DBBIT.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT * FROM Salidas where Numero = " + numero; //String Query1 = "Select * from SRDatosGenerales Where IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRTamanoTipo Where IDFormatoSillas = '"+idformatossillas+"'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable5"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; appPath = appPath + @"\huella.jpg"; DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }