private void printbillreport() { if (radioButtoncash.Checked) { textBoxcash.Text = textBoxGrandTotal.Text; } else if (radioButtoncredit.Checked) { textBoxcash.Text = "0"; } Int32 maxrowindex = dataGridView1.RowCount - 2; DialogResult dlgres = MessageBox.Show("Do you want to print the bill now?", "Print Bill Confirmation", MessageBoxButtons.YesNo); if (dlgres == DialogResult.Yes) { BillPrintingDataSet blprintdataset = new BillPrintingDataSet(); if (maxrowindex < 0 && oldbill==true) { maxrowindex++; } if (maxrowindex >= 0) { int i = 0; while (maxrowindex >= i) { if (replacementbill == true&&i==0) { blprintdataset.ItemsTable.AddItemsTableRow(dataGridView1.Rows[i].Cells[0].Value.ToString(), dataGridView1.Rows[i].Cells[1].Value.ToString(), dataGridView1.Rows[i].Cells[2].Value.ToString(), dataGridView1.Rows[i].Cells[3].Value.ToString(), "Replacement"); } else blprintdataset.ItemsTable.AddItemsTableRow(dataGridView1.Rows[i].Cells[0].Value.ToString(), dataGridView1.Rows[i].Cells[1].Value.ToString(), dataGridView1.Rows[i].Cells[2].Value.ToString(), dataGridView1.Rows[i].Cells[3].Value.ToString(), dataGridView1.Rows[i].Cells[4].Value.ToString()); i++; } BillingReport1 blreport = new BillingReport1(); blreport.SetDataSource(blprintdataset); //CrystalDecisions.Shared.ParameterValue parval = new CrystalDecisions.Shared.ParameterValue(); //blreport.ParameterFields[0].CurrentValues = textBoxBillNo.Text; //blreport.ParameterFields["billno"].DefaultValues.AddValue(textBoxBillNo.Text); //blreport.ParameterFields["billdate"].DefaultValues.AddValue(dateTimePickerbilldate.Value.ToShortDateString()); //blreport.ParameterFields["Customername"].DefaultValues.AddValue(comboBoxDealername.SelectedItem.ToString()); //blreport.ParameterFields["TotalAmount"].DefaultValues.AddValue(textBoxTotal.Text); // blreport.ParameterFields["TaxAmount"].DefaultValues.AddValue(textBoxTax.Text); // blreport.ParameterFields["DiscountAmount"].DefaultValues.AddValue(textBoxDiscount.Text); // blreport.ParameterFields["GrandTotal"].DefaultValues.AddValue(textBoxGrandTotal.Text); ParameterField pr = new ParameterField(); ParameterFields flds = new ParameterFields(); ParameterDiscreteValue pdv = new ParameterDiscreteValue(); pdv.Value = textBoxBillNo.Text; pr.Name = "billno"; pr.CurrentValues.Add(pdv); flds.Add(pr); pr = new ParameterField(); pdv = new ParameterDiscreteValue(); pdv.Value = dateTimePickerbilldate.Value.ToShortDateString(); pr.Name = "billdate"; pr.CurrentValues.Add(pdv); flds.Add(pr); pr = new ParameterField(); pdv = new ParameterDiscreteValue(); pdv.Value = comboBoxDealername.SelectedItem.ToString(); pr.Name = "Customername"; pr.CurrentValues.Add(pdv); flds.Add(pr); pr = new ParameterField(); pdv = new ParameterDiscreteValue(); pdv.Value = textBoxTotal.Text; pr.Name = "TotalAmount"; pr.CurrentValues.Add(pdv); flds.Add(pr); pr = new ParameterField(); pdv = new ParameterDiscreteValue(); pdv.Value = textBoxTax.Text; pr.Name = "TaxAmount"; pr.CurrentValues.Add(pdv); flds.Add(pr); pr = new ParameterField(); pdv = new ParameterDiscreteValue(); pdv.Value = textBoxDiscount.Text; pr.Name = "DiscountAmount"; pr.CurrentValues.Add(pdv); flds.Add(pr); pr = new ParameterField(); pdv = new ParameterDiscreteValue(); pdv.Value = textBoxGrandTotal.Text; pr.Name = "GrandTotal"; pr.CurrentValues.Add(pdv); flds.Add(pr); pr = new ParameterField(); pdv = new ParameterDiscreteValue(); pdv.Value = textBoxcash.Text; pr.Name = "cash"; pr.CurrentValues.Add(pdv); flds.Add(pr); // blreport.ParameterFields[0].CurrentValues = //blreport.SetParameterValue("billno", textBoxBillNo.Text); //blreport.SetParameterValue("billdate", dateTimePickerbilldate.Value.ToShortDateString()); //blreport.SetParameterValue("Customername", comboBoxDealername.SelectedItem.ToString()); //blreport.SetParameterValue("TotalAmount", textBoxTotal.Text); //blreport.SetParameterValue("TaxAmount", textBoxTax.Text); //blreport.SetParameterValue("DiscountAmount", textBoxDiscount.Text); //blreport.SetParameterValue("GrandTotal", textBoxGrandTotal.Text); ShowReports shwrep = new ShowReports(blreport,flds); shwrep.Show(); if (oldbill == false && parameterconstructorinvoke == false&&previewbill==false) { DialogResult dlgresult = MessageBox.Show("Do you want to view the report of productID and serial nos sold by this sale?", "Product ID and Serial Nos", MessageBoxButtons.YesNo); if (dlgresult == DialogResult.Yes) { ParameterFields pfieldsforbilledprods = new ParameterFields(); BilledProducts prodsbilled = new BilledProducts(); prodsbilled.SetDataSource(prodserial); pr = new ParameterField(); pdv = new ParameterDiscreteValue(); pdv.Value = textBoxBillNo.Text; pr.Name = "bill"; pr.CurrentValues.Add(pdv); pfieldsforbilledprods.Add(pr); ShowReports rpt = new ShowReports(prodsbilled, pfieldsforbilledprods); rpt.Show(); } } } else MessageBox.Show("insert items to Bill First"); } }
private void printserialno() { DialogResult rs = MessageBox.Show("Do you want to print the Serial Number labels for the updated stock products?", "Print Serial Numbers", MessageBoxButtons.YesNo); if (rs == DialogResult.Yes) { crystalreportserialno crys = new crystalreportserialno(); crys.SetDataSource(datasetserialno); ShowReports rpts = new ShowReports(crys); rpts.Show(); } }