protected void btnMonthWise_Click(object sender, EventArgs e) { //report.Load(Server.MapPath("~/Reports/AnyThreeMonths.rpt")); //report.FileName = Server.MapPath("~/Reports/AnyThreeMonths.rpt"); Reports.CrystalReport1 anyThree = new Reports.CrystalReport1(); int month1 = 0, month2 = 0, month3 = 0, year1 = 0, year2 = 0, year3 = 0; DataSet.DataSet1 ds = new DataSet.DataSet1(); string categ = ddlMonthwiseCategory.SelectedItem.ToString(); string[] month_arr = new string[lbMonth.Items.Count]; string[] year_arr = new string[lbMonth.Items.Count]; for (int i = 0; i < lbMonth.Items.Count; i++) { month_arr[i] = lbMonth.Items[i].ToString().Substring(5, 2); year_arr[i] = lbMonth.Items[i].ToString().Substring(0, 4); } if (month_arr.Count() > 0) { month1 = Convert.ToInt32(month_arr[0]); year1 = Convert.ToInt32(year_arr[0]); if (month_arr.Count() == 3) { month2 = Convert.ToInt32(month_arr[1]); year2 = Convert.ToInt32(year_arr[1]); month3 = Convert.ToInt32(month_arr[2]); year3 = Convert.ToInt32(year_arr[2]); } else if (month_arr.Count() == 2) { month2 = Convert.ToInt32(month_arr[1]); year2 = Convert.ToInt32(year_arr[1]); } } DataSet.DataSet1TableAdapters.AnythreeMonthReportTableAdapter ta = new DataSet.DataSet1TableAdapters.AnythreeMonthReportTableAdapter(); ta.Fill(ds.AnythreeMonthReport, month1, month2, month3, year1, year2, year3, categ); //DataSet1TableAdapters.threemonthsreportTableAdapter tmta = new DataSet1TableAdapters.threemonthsreportTableAdapter(); //tmta.Fill(ds.threemonthsreport, month1, month2, month3, categ); anyThree.SetDataSource(ds); //crp.SetDataSource(ds); CrView.ReportSource = anyThree; }
private void buttonInvoicePrint_Click(object sender, EventArgs e) { var UsedClass = new BasicClass(); var dt = new DataTable(); SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@InvoiceNo", SqlDbType.Int); param[1] = new SqlParameter("@CustomerName", SqlDbType.NVarChar, 250); param[0].Value = int.Parse(textBoxInvoiceNo.Text); param[1].Value = textBoxCustomerName.Text.Trim(); dt = UsedClass.selectdata("Casher_PrintForma", param); var crp = new Reports.CrystalReport1(); CrystalDecisions.CrystalReports.Engine.TextObject invoiceType = (CrystalDecisions.CrystalReports.Engine.TextObject)crp.ReportDefinition.Sections["Section2"].ReportObjects["Text15"]; invoiceType.Text = textBoxInvoiceNo.Text; crp.SetDataSource(dt); PrintForm form = new PrintForm(); form.crystalReportViewer1.ReportSource = crp; form.ShowDialog(); //crp.PrintToPrinter ( 1 , false , 0 , 0 ); }