private void GenerateInvoiceReport(CSOMaster oSOMaster) { POS posdateset = new POS(); DataTable dtInv = posdateset.Invoice; foreach (CSODetails oSODetails in oSOMaster.SOMstr_DetailsList) { DataRow drInv = dtInv.NewRow(); drInv["BranchName"] = currentBranch.CompBrn_Name; drInv["Address"] = currentBranch.CompBrn_Street; drInv["RoadNo"] = currentBranch.CompBrn_Road; drInv["City"] = currentBranch.CompBrn_City; drInv["Phone"] = currentBranch.CompBrn_Phone; drInv["InvoiceNo"] = oSOMaster.SOMstr_Code; drInv["VatClnNo"] = oSOMaster.SOMstr_VatClnNo; drInv["ItemName"] = oSODetails.SODet_ItemName; drInv["Qty"] = oSODetails.SODet_QTY; drInv["Price"] = oSODetails.SODet_Price; drInv["Amount"] = oSODetails.SODet_Amount; drInv["Discount"] = oSODetails.SODet_Discount; drInv["VATValue"] = oSODetails.SODet_VATValue; dtInv.Rows.Add(drInv); } rptInvoice objrptInvoice = new rptInvoice(); objrptInvoice.SetDataSource(dtInv); objrptInvoice.SetParameterValue(0, float.Parse(txtDiscountAmount.Text.Trim())); objrptInvoice.SetParameterValue(1, currentUser.User_UserName.Trim()); objrptInvoice.SetParameterValue(2, txtCustomerPaid.Text.Trim()); objrptInvoice.SetParameterValue(3, txtChange.Text.Trim()); if (InvoiceRawKind == 0) { PrintDocument pd = new PrintDocument(); pd.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("POS", 4, 4); InvoiceRawKind = (int)pd.PrinterSettings.DefaultPageSettings.PaperSize.RawKind; } objrptInvoice.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)InvoiceRawKind; objrptInvoice.PrintToPrinter(1, true, 1, 1); frmReportView ofrmReportView = new frmReportView(); CrystalReportViewer orptviewer = (CrystalReportViewer)ofrmReportView.Controls["rptviewer"]; orptviewer.ReportSource = objrptInvoice; orptviewer.AutoSize = false; orptviewer.Show(); ofrmReportView.Show(); }
private void button1_Click(object sender, EventArgs e) { //ReportDocument invoiceObjectReport = new ReportDocument(); ; //invoiceObjectReport.Load(Application.StartupPath + "\\rptInvoice.rpt"); m_AppController = new AppController(); CommandGetInvoices getInvoices = new CommandGetInvoices(); m_InvoiceList = (InvoiceList)m_AppController.ExecuteCommand(getInvoices); CommandGettingOutlet getOutlet = new CommandGettingOutlet(); m_OutletList = (outletList)m_AppController.ExecuteCommand(getOutlet); CommandGetRoti getRotis = new CommandGetRoti(); m_RotiToChooseList = (RotiToChooseList)m_AppController.ExecuteCommand(getRotis); CommandGetItem getInvoiceDetai = new CommandGetItem(); m_InvoiceDetailList = (RotiList)m_AppController.ExecuteCommand(getInvoiceDetai); //FieldingRw crInvoice = new FieldingRw(); rptInvoice crInvoice = new rptInvoice(); //rptSubReportInvoice crInvoice = new rptSubReportInvoice(); //Set DataSource First crInvoice.Database.Tables["Invoice_OTC_Model_InvoiceItem"].SetDataSource(m_InvoiceList); crInvoice.Subreports[0].Database.Tables["Invoice_OTC_Model_RotiToChooseItem"].SetDataSource(m_RotiToChooseList); crInvoice.Subreports[0].Database.Tables["Invoice_OTC_Model_RotiItem"].SetDataSource(m_InvoiceDetailList); crInvoice.Database.Tables["Invoice_OTC_Model_OutletItem"].SetDataSource(m_OutletList); //Set the parameter value crInvoice.SetParameterValue("nomorInvoice", nomorInvoice); crystalReportViewer1.ReportSource = crInvoice; crystalReportViewer1.Refresh(); }