c#


how to print multiple newly page for multiple different invoice number in c#.net using sap crystal report


I want to print multiple page according to their invoice number. For example, there is two option for print the bill that is from and to, it means from invoice number to to invoice number i.e. I want to print invoice number 6 to 10 and for different invoice number different page would be print. From my following code multiple page is showing but not according to the invoice number it showing according to the data[i.e. when the data is full on one page then it shows the second page]. But I don't want this one.
Here is my code,
try
{
string mtmptbl = "TmpTaxInvoicePrint";
RetailInvoicePrint frm = new RetailInvoicePrint();
Cursor = Cursors.WaitCursor;
ReportDocument cryRpt = new ReportDocument();
SqlCommand MyCommand = new SqlCommand();
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(cn.ConnectionString);
ConnectionInfo crConnectionInfo = new ConnectionInfo();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
string qryPreviewDocument = " SELECT Company.companyname, Company.address, Company.city, Company.state, Company.phono, Company.gtin as CompanyGTinNo, Company.ctin as CompanyCTinNo, Company.gtindate as CompanyGTinDate, " + System.Environment.NewLine;
qryPreviewDocument += " Client.clientname, Client.contactname, Client.billingaddrtess, Client.GTin as ClientGTinNo, Client.CTin as ClientCTinNo, Client.gtindate as ClientGTinDate, Client.ctindate as ClientCTinDate, " + System.Environment.NewLine;
qryPreviewDocument += " TaxInvoice.invoiceno, TaxInvoice.pono, TaxInvoice.pono2, TaxInvoice.pono3, TaxInvoice.pono4, " + System.Environment.NewLine;
qryPreviewDocument += " TaxInvoice.issuedate as IssueDate, " + System.Environment.NewLine;
qryPreviewDocument += " TaxInvoice.discount as Discount, TaxInvoice.shipping as Shipping, TaxInvoice.tax as Tax, TaxInvoice.vat as Vat, " + System.Environment.NewLine;
qryPreviewDocument += " TaxInvoice.sese as Sese, TaxInvoice.paymenttype as PaymentType, TaxInvoice.chequeno as Chequeno, TaxInvoice.totalamt as TotalAmt, " + System.Environment.NewLine;
qryPreviewDocument += " TaxInvoice.description as Description, TaxInvoice.paymentpaid as PaymentPaid, TaxInvoice.subtotal as Subtotal, " + System.Environment.NewLine;
qryPreviewDocument += " Product.productname as ProductName, TaxInvoiceProductDetail.uom as Uom, " + System.Environment.NewLine;
qryPreviewDocument += " TaxInvoiceProductDetail.quantity as Quantity, TaxInvoiceProductDetail.price as Price, " + System.Environment.NewLine;
qryPreviewDocument += " TaxInvoiceProductDetail.challanno as ChallanNo, TaxInvoiceProductDetail.issuedate as ChallanDate " + System.Environment.NewLine;
qryPreviewDocument += " into " + mtmptbl + " " + System.Environment.NewLine;
qryPreviewDocument += " from tbl_TaxInvoice TaxInvoice " + System.Environment.NewLine;
qryPreviewDocument += " LEFT OUTER JOIN tbl_TaxInvoiceProductDetail TaxInvoiceProductDetail ON TaxInvoice.invoiceno = TaxInvoiceProductDetail.invoiceno " + System.Environment.NewLine;
qryPreviewDocument += " LEFT OUTER JOIN tbl_clientdetail Client ON TaxInvoice.clientid = Client.clientid " + System.Environment.NewLine;
qryPreviewDocument += " LEFT OUTER JOIN tbl_companydetail Company ON TaxInvoice.BranchID = Company.companyid " + System.Environment.NewLine;
qryPreviewDocument += " LEFT OUTER JOIN tbl_product Product ON TaxInvoiceProductDetail.productid = Product.productid " + System.Environment.NewLine;
qryPreviewDocument += " where TaxInvoice.BranchID = " + lbl_branchid.Text + " " + System.Environment.NewLine;
qryPreviewDocument += " and TaxInvoice.YearID = " + lbl_yearid.Text + " " + System.Environment.NewLine;
qryPreviewDocument += " and TaxInvoice.invoiceno = " + txt_invoice.Text + "";
qryPreviewDocument += " and TaxInvoiceProductDetail.BranchID = " + lbl_branchid.Text + " " + System.Environment.NewLine;
qryPreviewDocument += " and TaxInvoiceProductDetail.YearID = " + lbl_yearid.Text + " " + System.Environment.NewLine;
qryPreviewDocument += " and TaxInvoiceProductDetail.invoiceno = " + txt_invoice.Text + "";
string SQL = "select upper(name) as TABLE_NAME FROM sysobjects WHERE type = 'U' and name = '" + mtmptbl + "' order by name";
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(SQL, cn);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
string qrydrop = "drop table " + mtmptbl + "";
SqlCommand cmd = new SqlCommand(qrydrop, cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
MyCommand = new SqlCommand(qryPreviewDocument, cn);
MyCommand.CommandType = CommandType.Text;
cn.Open();
MyCommand.ExecuteNonQuery();
//Add BillType field to the tmptable
using (MyCommand = new SqlCommand("alter table [" + mtmptbl + "] add [billtype] varchar(20) NULL", cn))
{
MyCommand.CommandType = CommandType.Text;
MyCommand.ExecuteNonQuery();
}
cn.Close();
string crReportPath = Application.StartupPath.Replace("bin\\Debug", "") + "\\Print";
cryRpt.Load(crReportPath + "\\RptTaxInvoicePrint.rpt");
builder.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["con"];
string dbName = builder.InitialCatalog;
string dbDataSource = builder.DataSource;
string userID = builder.UserID;
string pass = builder.Password;
crConnectionInfo.ServerName = dbDataSource;
crConnectionInfo.DatabaseName = dbName;
crConnectionInfo.UserID = userID;
crConnectionInfo.Password = pass;
Tables Crtables;
Crtables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in Crtables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
frm.crystalReportViewer1.ReportSource = cryRpt;
frm.crystalReportViewer1.RefreshReport();
Cursor = Cursors.Arrow;
frm.Show();
btn_reset.Focus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Thanks In Advance
This can be done by add the groupheadersection to the invoice no.

Related Links

EditorForTemplate inside a DisplayForTemplate MVC Razor
Querying a MongoDB database
Using linq to group a table that contains substrings
Web Application Layers Naming Convention
Why Array.Reverse(myCharArray) and not myCharArray=myCharArray.Reverse?
Confusion when using #model in Razor with Http Post
Calling a unmanaged C method with a const char** argument from managed C# code
Access and overwrite an xml node (C#)
Persist cookies across multiple requests
How to handle switch user in c#?
Limit the maximum number of characters in a double
Hosting ASP.net app on somee - database update from C# app
I have a deserialize Json C# class now i want to fetch information from it
Lightswitch - C# LINQ Preprocess Query
Passing arguments to a .NET exe file with _spawnv
Backgroundwork DoWork process not running after installing application

Categories

HOME
netty
ldap
weblogic
bigtable
lithium
ebay
servicenow
opacity
kendo-asp.net-mvc
zabbix
pip
dcos
oms
mamp
email-attachments
browsermob
cakephp-2.0
derby
accordion
bug-reporting
android-navigation-drawer
typedef
rvm
v4l2
handle
oracle10g
tftp
proof-general
ds-5
semantic-ui-react
concrete5
powerbi-embedded
wunderground
leaderboard
multi-user
oracle-bpm-suite
queryover
tapply
vertical-alignment
java-5
amazon-fire-tv
line-endings
serverless-architecture
stream-socket-client
pyopenssl
google-cloud-shell
bioperl
aot
try-catch-finally
reloaddata
cardview
directinput
mac-app-store
xcode7.1
altova
db2-zos
angularfire
kik
avaudiorecorder
jmh
nd4j
ideavim
updating
mergecursor
autopep8
mri
backtrace
aiff
random-access
qf-test
clearcanvas
react-os
zoneminder
image-preloader
db2-connect
codio
raddatepicker
http-compression
pageload
ftpwebrequest
gssapi
nude.js
socketasynceventargs
zend-validate
mcpd
digg
zipstream
cpack
qprocess
glassfish-embedded
moores-law
scalable

Resources

Encrypt Message