private void button_Click() { ReportDocument cryRpt = new ReportDocument(); cryRpt.Load(@"Reports\DatewiseSupplierReport.rpt"); frm_ReportForm _report = new frm_ReportForm(); TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); TableLogOnInfo crtableLogoninfo = new TableLogOnInfo(); ConnectionInfo crConnectionInfo = new ConnectionInfo(); Tables CrTables; SqlConnection con = new SqlConnection(); string[] conString = DBSettings.connectionStringValues(); string connectionString = string.Format(@"server=" + conString[0] + ";database=restaurant;uid=" + conString[2] + ";pwd=" + conString[3]); con.ConnectionString = connectionString; con.Open(); crConnectionInfo.ServerName = conString[0]; crConnectionInfo.DatabaseName = "restaurant"; crConnectionInfo.UserID = conString[2]; crConnectionInfo.Password = conString[3]; ParameterFieldDefinitions crParameterFieldDefinitions; ParameterFieldDefinition crParameterFieldDefinition; ParameterValues crParameterValues = new ParameterValues(); ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue(); crParameterDiscreteValue.Value = cmb_SupplierName.Text; crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields; crParameterFieldDefinition = crParameterFieldDefinitions["SupplierName"]; crParameterValues = crParameterFieldDefinition.CurrentValues; crParameterValues.Clear(); crParameterValues.Add(crParameterDiscreteValue); crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); crParameterDiscreteValue.Value = dateTimePicker1.Value.ToString(); crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields; crParameterFieldDefinition = crParameterFieldDefinitions["fromDate"]; crParameterValues = crParameterFieldDefinition.CurrentValues; crParameterValues.Clear(); crParameterValues.Add(crParameterDiscreteValue); crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); crParameterDiscreteValue.Value = dateTimePicker2.Value.ToString(); crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields; crParameterFieldDefinition = crParameterFieldDefinitions["toDate"]; crParameterValues = crParameterFieldDefinition.CurrentValues; crParameterValues.Add(crParameterDiscreteValue); crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); CrTables = cryRpt.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { crtableLogoninfo = CrTable.LogOnInfo; crtableLogoninfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(crtableLogoninfo); } crystalReportViewer2.ReportSource = cryRpt; crystalReportViewer2.Refresh(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)