Add Name Spaces and create object of .xsd file and Report Document in global section.than do the code like this...
private void fill_report()
{
try
{
int InvoiceId;
int BookingId;
View_All_Invoice_Room all_invoice = new View_All_Invoice_Room();
ReportDocument rd = new ReportDocument();
DataTable dtt = new DataTable();
DataTable dtroomservice = new DataTable();
DataTable dttoors = new DataTable();
DataTable dtlaundry = new DataTable();
DataTable dtinternet = new DataTable();
rd.Load(Server.MapPath("~/") + "Invoice_Rpt" + "\\" + "View_All_Invoice_Room.rpt");
List objlist = new List();
List lstroom_service = new List();
List lstroom = new List();
string PdfName = string.Empty;
DataTable dthotel = new DataTable();
InvoiceId = Convert.ToInt32(ViewState["invoiceid"].ToString());
dtt = objlist.queryList("SELECT tblInvoice.CustomerName, convert(varchar,tblInvoice.CheckOutDate,101) AS CheckOutDate,convert(varchar,tblBookingList.CheckInDate,101) AS CheckInDate, tblInvoice.BookingID, tblRoom.RoomNo, tblFinalInvoicePayment.RoomTotal, " +
"tblFinalInvoicePayment.Advance,tblFinalInvoicePayment.AddextaCharges,tblFinalInvoicePayment.DeductCharges, tblFinalInvoicePayment.GuestAdvance, tblFinalInvoicePayment.RoomServices, " +
"tblFinalInvoicePayment.LaundryServices, tblFinalInvoicePayment.InternetServices, tblFinalInvoicePayment.ToorsServices, " +
"tblFinalInvoicePayment.FinalTotal, tblInvoice.InvoiceID, tblCustomer.CustomerName AS CustName, tblCustomer.CompanyName, tblCustomer.Address, " +
"tblCustomer.EmailId, tblCustomer.MobileNo " +
"FROM tblhoteldetails INNER JOIN " +
"tblCustomer ON tblhoteldetails.HotelID = tblCustomer.HotelID INNER JOIN " +
"tblBookingDetail ON tblhoteldetails.HotelID = tblBookingDetail.HotelID INNER JOIN " +
"tblBookingList ON tblhoteldetails.HotelID = tblBookingList.HotelID INNER JOIN " +
"tblFinalInvoicePayment ON tblhoteldetails.HotelID = tblFinalInvoicePayment.HotelID INNER JOIN " +
"tblRoom ON tblhoteldetails.HotelID = tblRoom.HotelID AND tblBookingDetail.RoomID = tblRoom.RoomID INNER JOIN " +
"tblInvoice ON tblhoteldetails.HotelID = tblInvoice.HotelID AND tblFinalInvoicePayment.InvoiceID = tblInvoice.InvoiceID AND " +
"tblBookingDetail.BookingID = tblInvoice.BookingID AND tblCustomer.CustomerName = tblInvoice.CustomerName AND " +
"tblBookingList.BookingID = tblInvoice.BookingID " +
"WHERE tblInvoice.InvoiceID = " + InvoiceId + "");
BookingId = Convert.ToInt32(dtt.Rows[0]["BookingID"].ToString());
DataTable dtroom = lstroom.queryList("select R.RoomNo from tblBookingDetail AS BD,tblRoom as R where BD.RoomID=R.RoomID And bd.BookingID=" + BookingId + "");
for (int j = 0; j < dtroom.Rows.Count; j++)
{
dtroomservice = lstroom_service.queryList("SELECT CONVERT(VARCHAR(50),ri.[ServiceDate],101) AS ServiceDate,ri.[RoomNo],rs.[Menu],rs.[ServiceName],CAST(rs.RoomServiceID AS Varchar(20)) AS RoomServiceID,rs.[Quantity],CAST(rs.[Rate] AS varchar(12)) AS Rate ,CAST(rs.[TotalAmount] AS varchar(12)) AS TotalAmount FROM [tblRoomInform] AS ri INNER JOIN [tblRoomServices] AS rs ON ri.[RoomInformID] = rs.[RoomInformID] WHERE ri.RoomNo='" + dtroom.Rows[j]["RoomNo"].ToString() + "' AND ri.[BookingID]=" + BookingId + "");
}
if (dtroomservice.Rows.Count > 0)
{
for (int rs = 0; rs < dtroomservice.Rows.Count; rs++)
{
DataRow rs_dr = all_invoice.DTAllServices.NewRow();
rs_dr["RsInvoiceId"] = dtroomservice.Rows[rs]["RoomServiceID"];
rs_dr["RsServiceDate"] = dtroomservice.Rows[rs]["ServiceDate"];
rs_dr["RsRoomNo"] = dtroomservice.Rows[rs]["RoomNo"];
rs_dr["RsMenu"] = dtroomservice.Rows[rs]["Menu"];
rs_dr["RsQuentity"] = dtroomservice.Rows[rs]["Quantity"];
rs_dr["RsRate"] = dtroomservice.Rows[rs]["Rate"];
rs_dr["RsServiceDate"] = dtroomservice.Rows[rs]["ServiceDate"];
rs_dr["RsTotal"] = dtroomservice.Rows[rs]["TotalAmount"];
all_invoice.DTAllServices.Rows.Add(rs_dr);
}
}
else
{
//DataRow rs_dr = all_invoice.DTAllServices.NewRow();
//rs_dr["RsInvoiceId"] = "Nill";
//rs_dr["RsServiceDate"] = "Nill";
//rs_dr["RsRoomNo"] = "Nill";
//rs_dr["RsMenu"] = "Nill";
//rs_dr["RsQuentity"] = Convert.ToInt32(0);
//rs_dr["RsRate"] = Convert.ToDecimal(0);
//rs_dr["RsServiceDate"] = "Nill";
//rs_dr["RsTotal"] = Convert.ToDecimal(0);
//all_invoice.DTAllServices.Rows.Add(rs_dr);
}
List lstoors = new List();
dttoors = lstoors.queryList("SELECT ROW_NUMBER()OVER(ORDER BY li.CarCheckInID) AS SrNo,CAST(li.CarCheckInID AS varchar(20)) AS CarCheckInID, li.BookingID,ld.CarName,ld.StartTime,ld.EndTime,ld.StartKm,ld.EndKm,CAST(ld.Rate AS varchar(12)) AS Rate,CONVERT(VARCHAR(20),ld.CurrentDate,101) AS CurrentDate FROM tblCarCheckIn AS li INNER JOIN tblCarCheckInDetails AS ld ON li.CarCheckInID=ld.CarCheckInID WHERE li.BookingID=" + BookingId + "");
if (dttoors.Rows.Count > 0)
{
for (int tt = 0; tt < dttoors.Rows.Count; tt++)
{
DataRow tt_dr = all_invoice.DTTourTrav.NewRow();
tt_dr["TTInvoiceId"] = dttoors.Rows[0]["CarCheckInID"];
tt_dr["TTServices"] = dttoors.Rows[tt]["CurrentDate"];
tt_dr["TTCarName"] = dttoors.Rows[tt]["CarName"];
tt_dr["TTStartTime"] = dttoors.Rows[tt]["StartTime"];
tt_dr["TTEndTime"] = dttoors.Rows[tt]["EndTime"];
tt_dr["TTStartKM"] = dttoors.Rows[tt]["StartKm"];
tt_dr["TTEndKM"] = dttoors.Rows[tt]["EndKm"];
tt_dr["TTTotal"] = dttoors.Rows[tt]["Rate"];
all_invoice.DTTourTrav.Rows.Add(tt_dr);
}
}
else
{
//DataRow tt_dr = all_invoice.DTTourTrav.NewRow();
//tt_dr["TTInvoiceId"] = "Nill";
//tt_dr["TTServices"] = "Nill";
//tt_dr["TTCarName"] = "Nill";
//tt_dr["TTStartTime"] = "Nill";
//tt_dr["TTEndTime"] = "Nill";
//tt_dr["TTStartKM"] = Convert.ToInt32(0);
//tt_dr["TTEndKM"] = Convert.ToInt32(0);
//tt_dr["TTTotal"] = Convert.ToDecimal(0);
//all_invoice.DTTourTrav.Rows.Add(tt_dr);
}
List lslaundry = new List();
dtlaundry = lslaundry.queryList("SELECT ROW_NUMBER()OVER(ORDER BY li.LaundryListID) AS SrNo,CAST(li.LaundryListID AS varchar(20)) AS LaundryListID, li.BookingID,ld.RoomNo,ld.LItemName,CAST(ld.LRate AS varchar(12)) AS LRate,ld.LQuantity,CAST(ld.TotalAmount AS varchar(12)) AS TotalAmount,CONVERT(VARCHAR(20),ld.CurrentDate,101) AS CurrentDate FROM tblLaundryList AS li INNER JOIN tblLaundryDetails AS ld ON li.LaundryListID=ld.LaundryListID WHERE li.BookingID=" + BookingId + "");
if (dtlaundry.Rows.Count > 0)
{
for (int ld = 0; ld < dtlaundry.Rows.Count; ld++)
{
DataRow ld_dr = all_invoice.DTAllLaundry.NewRow();
ld_dr["LdInvoiceId"] = dtlaundry.Rows[0]["LaundryListID"];
ld_dr["LdServiceDate"] = dtlaundry.Rows[ld]["CurrentDate"];
ld_dr["LdRoomNo"] = dtlaundry.Rows[ld]["RoomNo"];
ld_dr["LdItemName"] = dtlaundry.Rows[ld]["LItemName"];
ld_dr["LdQuentity"] = dtlaundry.Rows[ld]["LQuantity"];
ld_dr["LdRate"] = dtlaundry.Rows[ld]["LRate"];
ld_dr["LdTotal"] = dtlaundry.Rows[ld]["TotalAmount"];
all_invoice.DTAllLaundry.Rows.Add(ld_dr);
}
}
else
{
//DataRow ld_dr = all_invoice.DTAllLaundry.NewRow();
//ld_dr["LdInvoiceId"] = "Nill";
//ld_dr["LdServiceDate"] = "Nill";
//ld_dr["LdRoomNo"] = "Nill";
//ld_dr["LdItemName"] = "Nill";
//ld_dr["LdQuentity"] = Convert.ToInt32(0);
//ld_dr["LdRate"] = Convert.ToDecimal(0);
//ld_dr["LdTotal"] = Convert.ToDecimal(0);
//all_invoice.DTAllLaundry.Rows.Add(ld_dr);
}
List lsinternet = new List();
dtinternet = lsinternet.queryList("SELECT ROW_NUMBER()OVER(ORDER BY li.InternetListID) AS SrNo,CAST(li.InternetListID AS varchar(20)) AS InternetListID, li.BookingID,ld.RoomNo,ld.IItemName,CAST(ld.IRate AS varchar(12)) AS IRate,ld.IQuantity,CAST(ld.TotalAmount AS varchar(12)) AS TotalAmount,CONVERT(VARCHAR(20),ld.CurrentDate,101) AS CurrentDate FROM tblInternetList AS li INNER JOIN tblInternetDetail AS ld ON li.InternetListID=ld.InternetListID WHERE li.BookingID=" + BookingId + "");
if (dtinternet.Rows.Count > 0)
{
for (int it = 0; it < dtinternet.Rows.Count; it++)
{
DataRow it_dr = all_invoice.DTAllInterTele.NewRow();
it_dr["ITInvoiceId"] = dtinternet.Rows[0]["InternetListID"];
it_dr["ITServiceDate"] = dtinternet.Rows[it]["CurrentDate"];
it_dr["ITRoomNo"] = dtinternet.Rows[it]["RoomNo"];
it_dr["ITItemName"] = dtinternet.Rows[it]["IItemName"];
it_dr["ITHour"] = dtinternet.Rows[it]["IQuantity"];
it_dr["ITRate"] = dtinternet.Rows[it]["IRate"];
it_dr["ITTotal"] = dtinternet.Rows[it]["TotalAmount"];
all_invoice.DTAllInterTele.Rows.Add(it_dr);
}
}
else
{
//DataRow it_dr = all_invoice.DTAllInterTele.NewRow();
//it_dr["ITInvoiceId"] = "Nill";
//it_dr["ITServiceDate"] = "Nill";
//it_dr["ITRoomNo"] = "Nill";
//it_dr["ITItemName"] = "Nill";
//it_dr["ITHour"] = Convert.ToInt32(0);
//it_dr["ITRate"] = Convert.ToDecimal(0);
//it_dr["ITTotal"] = Convert.ToDecimal(0);
//all_invoice.DTAllInterTele.Rows.Add(it_dr);
}
if (dtt.Rows.Count > 0)
{
for (int i = 0; i < dtt.Rows.Count; i++)
{
List objhotel = new List();
dthotel = objhotel.queryList("select HotelName,Address,City,Currencies,tblcountry.countryname,tblstate.statename from tblHotelDetails h left join tblcountry on tblcountry.countryid=h.countryid left join tblstate on tblstate.stateid=h.stateid where HotelID= '" + hotelid + "'");
DataRow dr = all_invoice.DTAllInvoice.NewRow();
dr["HotelName"] = dthotel.Rows[0]["HotelName"];
dr["HAddress"] = dthotel.Rows[0]["Address"];
dr["HCity"] = dthotel.Rows[0]["City"];
dr["HState"] = dthotel.Rows[0]["statename"];
dr["HCountry"] = dthotel.Rows[0]["countryname"];
dr["InvoiceId"] = Convert.ToInt32(InvoiceId);
dr["BookingId"] = dtt.Rows[0]["BookingID"];
dr["CheckOutDate"] = dtt.Rows[0]["CheckOutDate"];
dr["CheckInDate"] = dtt.Rows[0]["CheckInDate"];
dr["RoomNo"] = dtroom.Rows[0]["RoomNo"];
//List lsroom = new List();
//DataTable dtroom = lsroom.queryList("SELECT R.RoomNo FROM tblBookingDetail AS BD INNER JOIN tblRoom AS R ON BD.RoomID = R.RoomID WHERE BD.BookingID = '" + BookingId + "'");
for (int r = 1; r < dtroom.Rows.Count; r++)
{
dr["RoomNo"] = dr["RoomNo"] + ", " + dtroom.Rows[r]["RoomNo"];
}
dr["RoomAmt"] = dtt.Rows[0]["RoomTotal"];
dr["AdvanceAmt"] = dtt.Rows[0]["Advance"];
dr["RoomServicesAmt"] = dtt.Rows[0]["RoomServices"];
dr["LaundryAmt"] = dtt.Rows[0]["LaundryServices"];
dr["Inter-teleAmt"] = dtt.Rows[0]["InternetServices"];
dr["Tours-TravAmt"] = dtt.Rows[0]["ToorsServices"];
dr["CustAddress"] = dtt.Rows[0]["Address"];
dr["CustName"] = dtt.Rows[0]["CustomerName"];
dr["CustMobile"] = dtt.Rows[0]["MobileNo"];
dr["CustEmail"] = dtt.Rows[0]["EmailId"];
dr["CustCompanyName"] = dtt.Rows[0]["CompanyName"];
dr["extraamt"] = dtt.Rows[0]["AddextaCharges"];
dr["deductamt"] = dtt.Rows[0]["DeductCharges"];
all_invoice.DTAllInvoice.Rows.Add(dr);
}
}
rd.SetDataSource(all_invoice);
rd.OpenSubreport("RS_All_Invoice_Room.rpt").SetDataSource(all_invoice);
rd.OpenSubreport("LD_All_Invoice_Room.rpt").SetDataSource(all_invoice);
rd.OpenSubreport("IT_All_Invoice_Room.rpt").SetDataSource(all_invoice);
rd.OpenSubreport("TT_All_Invoice_Room.rpt").SetDataSource(all_invoice);
TextObject txtadamtr = (TextObject)rd.ReportDefinition.ReportObjects["txtadamt"];
TextObject txtpendingamtr = (TextObject)rd.ReportDefinition.ReportObjects["txtpendingamt"];
TextObject txtextrachrgr = (TextObject)rd.ReportDefinition.ReportObjects["txtexchrg"];
TextObject txtdeductamtr = (TextObject)rd.ReportDefinition.ReportObjects["txtdeductamt"];
TextObject txtrsgtotalr = (TextObject)rd.OpenSubreport("RS_All_Invoice_Room.rpt").ReportDefinition.ReportObjects["txtrsgtotal"];
TextObject txtldgtotalr = (TextObject)rd.OpenSubreport("LD_All_Invoice_Room.rpt").ReportDefinition.ReportObjects["txtldgtotal"];
TextObject txtitgtotalr = (TextObject)rd.OpenSubreport("IT_All_Invoice_Room.rpt").ReportDefinition.ReportObjects["txtitgtotal"];
TextObject txtttgtotalr = (TextObject)rd.OpenSubreport("TT_All_Invoice_Room.rpt").ReportDefinition.ReportObjects["txtttgtotal"];
txtadamtr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtpendingamtr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtextrachrgr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtdeductamtr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtrsgtotalr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtldgtotalr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtitgtotalr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtttgtotalr.Text = dthotel.Rows[0]["Currencies"].ToString();
string Invoice_Folder = "Invoice_PDF";
string ModuleName = "RoomManagement";
string old =hotelid.ToString();
bool isexist = System.IO.Directory.Exists(Server.MapPath("~/") + "\\" + Invoice_Folder + "\\" + old + "\\" + ModuleName);
if (!isexist)
{
Directory.CreateDirectory(Server.MapPath("~/") + "\\" + Invoice_Folder + "\\" + old + "\\" + ModuleName);
}
PdfName = InvoiceId.ToString() + "FinalInvoice" + "_" + DateTime.Today.ToString("MM-dd-yyyy") + ".pdf";
rd.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("~/") + "\\" + Invoice_Folder + "\\" + old + "\\" + ModuleName + "\\" + PdfName);
List lstpdf = new List();
lstpdf.queryList("Update tblinvoice Set InvoiceImage='" + PdfName.ToString() + "' where InvoiceID=" + InvoiceId + " and HotelID=" + hotelid + "");
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
private void fill_report()
{
try
{
int InvoiceId;
int BookingId;
View_All_Invoice_Room all_invoice = new View_All_Invoice_Room();
ReportDocument rd = new ReportDocument();
DataTable dtt = new DataTable();
DataTable dtroomservice = new DataTable();
DataTable dttoors = new DataTable();
DataTable dtlaundry = new DataTable();
DataTable dtinternet = new DataTable();
rd.Load(Server.MapPath("~/") + "Invoice_Rpt" + "\\" + "View_All_Invoice_Room.rpt");
List objlist = new List();
List lstroom_service = new List();
List lstroom = new List();
string PdfName = string.Empty;
DataTable dthotel = new DataTable();
InvoiceId = Convert.ToInt32(ViewState["invoiceid"].ToString());
dtt = objlist.queryList("SELECT tblInvoice.CustomerName, convert(varchar,tblInvoice.CheckOutDate,101) AS CheckOutDate,convert(varchar,tblBookingList.CheckInDate,101) AS CheckInDate, tblInvoice.BookingID, tblRoom.RoomNo, tblFinalInvoicePayment.RoomTotal, " +
"tblFinalInvoicePayment.Advance,tblFinalInvoicePayment.AddextaCharges,tblFinalInvoicePayment.DeductCharges, tblFinalInvoicePayment.GuestAdvance, tblFinalInvoicePayment.RoomServices, " +
"tblFinalInvoicePayment.LaundryServices, tblFinalInvoicePayment.InternetServices, tblFinalInvoicePayment.ToorsServices, " +
"tblFinalInvoicePayment.FinalTotal, tblInvoice.InvoiceID, tblCustomer.CustomerName AS CustName, tblCustomer.CompanyName, tblCustomer.Address, " +
"tblCustomer.EmailId, tblCustomer.MobileNo " +
"FROM tblhoteldetails INNER JOIN " +
"tblCustomer ON tblhoteldetails.HotelID = tblCustomer.HotelID INNER JOIN " +
"tblBookingDetail ON tblhoteldetails.HotelID = tblBookingDetail.HotelID INNER JOIN " +
"tblBookingList ON tblhoteldetails.HotelID = tblBookingList.HotelID INNER JOIN " +
"tblFinalInvoicePayment ON tblhoteldetails.HotelID = tblFinalInvoicePayment.HotelID INNER JOIN " +
"tblRoom ON tblhoteldetails.HotelID = tblRoom.HotelID AND tblBookingDetail.RoomID = tblRoom.RoomID INNER JOIN " +
"tblInvoice ON tblhoteldetails.HotelID = tblInvoice.HotelID AND tblFinalInvoicePayment.InvoiceID = tblInvoice.InvoiceID AND " +
"tblBookingDetail.BookingID = tblInvoice.BookingID AND tblCustomer.CustomerName = tblInvoice.CustomerName AND " +
"tblBookingList.BookingID = tblInvoice.BookingID " +
"WHERE tblInvoice.InvoiceID = " + InvoiceId + "");
BookingId = Convert.ToInt32(dtt.Rows[0]["BookingID"].ToString());
DataTable dtroom = lstroom.queryList("select R.RoomNo from tblBookingDetail AS BD,tblRoom as R where BD.RoomID=R.RoomID And bd.BookingID=" + BookingId + "");
for (int j = 0; j < dtroom.Rows.Count; j++)
{
dtroomservice = lstroom_service.queryList("SELECT CONVERT(VARCHAR(50),ri.[ServiceDate],101) AS ServiceDate,ri.[RoomNo],rs.[Menu],rs.[ServiceName],CAST(rs.RoomServiceID AS Varchar(20)) AS RoomServiceID,rs.[Quantity],CAST(rs.[Rate] AS varchar(12)) AS Rate ,CAST(rs.[TotalAmount] AS varchar(12)) AS TotalAmount FROM [tblRoomInform] AS ri INNER JOIN [tblRoomServices] AS rs ON ri.[RoomInformID] = rs.[RoomInformID] WHERE ri.RoomNo='" + dtroom.Rows[j]["RoomNo"].ToString() + "' AND ri.[BookingID]=" + BookingId + "");
}
if (dtroomservice.Rows.Count > 0)
{
for (int rs = 0; rs < dtroomservice.Rows.Count; rs++)
{
DataRow rs_dr = all_invoice.DTAllServices.NewRow();
rs_dr["RsInvoiceId"] = dtroomservice.Rows[rs]["RoomServiceID"];
rs_dr["RsServiceDate"] = dtroomservice.Rows[rs]["ServiceDate"];
rs_dr["RsRoomNo"] = dtroomservice.Rows[rs]["RoomNo"];
rs_dr["RsMenu"] = dtroomservice.Rows[rs]["Menu"];
rs_dr["RsQuentity"] = dtroomservice.Rows[rs]["Quantity"];
rs_dr["RsRate"] = dtroomservice.Rows[rs]["Rate"];
rs_dr["RsServiceDate"] = dtroomservice.Rows[rs]["ServiceDate"];
rs_dr["RsTotal"] = dtroomservice.Rows[rs]["TotalAmount"];
all_invoice.DTAllServices.Rows.Add(rs_dr);
}
}
else
{
//DataRow rs_dr = all_invoice.DTAllServices.NewRow();
//rs_dr["RsInvoiceId"] = "Nill";
//rs_dr["RsServiceDate"] = "Nill";
//rs_dr["RsRoomNo"] = "Nill";
//rs_dr["RsMenu"] = "Nill";
//rs_dr["RsQuentity"] = Convert.ToInt32(0);
//rs_dr["RsRate"] = Convert.ToDecimal(0);
//rs_dr["RsServiceDate"] = "Nill";
//rs_dr["RsTotal"] = Convert.ToDecimal(0);
//all_invoice.DTAllServices.Rows.Add(rs_dr);
}
List lstoors = new List();
dttoors = lstoors.queryList("SELECT ROW_NUMBER()OVER(ORDER BY li.CarCheckInID) AS SrNo,CAST(li.CarCheckInID AS varchar(20)) AS CarCheckInID, li.BookingID,ld.CarName,ld.StartTime,ld.EndTime,ld.StartKm,ld.EndKm,CAST(ld.Rate AS varchar(12)) AS Rate,CONVERT(VARCHAR(20),ld.CurrentDate,101) AS CurrentDate FROM tblCarCheckIn AS li INNER JOIN tblCarCheckInDetails AS ld ON li.CarCheckInID=ld.CarCheckInID WHERE li.BookingID=" + BookingId + "");
if (dttoors.Rows.Count > 0)
{
for (int tt = 0; tt < dttoors.Rows.Count; tt++)
{
DataRow tt_dr = all_invoice.DTTourTrav.NewRow();
tt_dr["TTInvoiceId"] = dttoors.Rows[0]["CarCheckInID"];
tt_dr["TTServices"] = dttoors.Rows[tt]["CurrentDate"];
tt_dr["TTCarName"] = dttoors.Rows[tt]["CarName"];
tt_dr["TTStartTime"] = dttoors.Rows[tt]["StartTime"];
tt_dr["TTEndTime"] = dttoors.Rows[tt]["EndTime"];
tt_dr["TTStartKM"] = dttoors.Rows[tt]["StartKm"];
tt_dr["TTEndKM"] = dttoors.Rows[tt]["EndKm"];
tt_dr["TTTotal"] = dttoors.Rows[tt]["Rate"];
all_invoice.DTTourTrav.Rows.Add(tt_dr);
}
}
else
{
//DataRow tt_dr = all_invoice.DTTourTrav.NewRow();
//tt_dr["TTInvoiceId"] = "Nill";
//tt_dr["TTServices"] = "Nill";
//tt_dr["TTCarName"] = "Nill";
//tt_dr["TTStartTime"] = "Nill";
//tt_dr["TTEndTime"] = "Nill";
//tt_dr["TTStartKM"] = Convert.ToInt32(0);
//tt_dr["TTEndKM"] = Convert.ToInt32(0);
//tt_dr["TTTotal"] = Convert.ToDecimal(0);
//all_invoice.DTTourTrav.Rows.Add(tt_dr);
}
List lslaundry = new List();
dtlaundry = lslaundry.queryList("SELECT ROW_NUMBER()OVER(ORDER BY li.LaundryListID) AS SrNo,CAST(li.LaundryListID AS varchar(20)) AS LaundryListID, li.BookingID,ld.RoomNo,ld.LItemName,CAST(ld.LRate AS varchar(12)) AS LRate,ld.LQuantity,CAST(ld.TotalAmount AS varchar(12)) AS TotalAmount,CONVERT(VARCHAR(20),ld.CurrentDate,101) AS CurrentDate FROM tblLaundryList AS li INNER JOIN tblLaundryDetails AS ld ON li.LaundryListID=ld.LaundryListID WHERE li.BookingID=" + BookingId + "");
if (dtlaundry.Rows.Count > 0)
{
for (int ld = 0; ld < dtlaundry.Rows.Count; ld++)
{
DataRow ld_dr = all_invoice.DTAllLaundry.NewRow();
ld_dr["LdInvoiceId"] = dtlaundry.Rows[0]["LaundryListID"];
ld_dr["LdServiceDate"] = dtlaundry.Rows[ld]["CurrentDate"];
ld_dr["LdRoomNo"] = dtlaundry.Rows[ld]["RoomNo"];
ld_dr["LdItemName"] = dtlaundry.Rows[ld]["LItemName"];
ld_dr["LdQuentity"] = dtlaundry.Rows[ld]["LQuantity"];
ld_dr["LdRate"] = dtlaundry.Rows[ld]["LRate"];
ld_dr["LdTotal"] = dtlaundry.Rows[ld]["TotalAmount"];
all_invoice.DTAllLaundry.Rows.Add(ld_dr);
}
}
else
{
//DataRow ld_dr = all_invoice.DTAllLaundry.NewRow();
//ld_dr["LdInvoiceId"] = "Nill";
//ld_dr["LdServiceDate"] = "Nill";
//ld_dr["LdRoomNo"] = "Nill";
//ld_dr["LdItemName"] = "Nill";
//ld_dr["LdQuentity"] = Convert.ToInt32(0);
//ld_dr["LdRate"] = Convert.ToDecimal(0);
//ld_dr["LdTotal"] = Convert.ToDecimal(0);
//all_invoice.DTAllLaundry.Rows.Add(ld_dr);
}
List lsinternet = new List();
dtinternet = lsinternet.queryList("SELECT ROW_NUMBER()OVER(ORDER BY li.InternetListID) AS SrNo,CAST(li.InternetListID AS varchar(20)) AS InternetListID, li.BookingID,ld.RoomNo,ld.IItemName,CAST(ld.IRate AS varchar(12)) AS IRate,ld.IQuantity,CAST(ld.TotalAmount AS varchar(12)) AS TotalAmount,CONVERT(VARCHAR(20),ld.CurrentDate,101) AS CurrentDate FROM tblInternetList AS li INNER JOIN tblInternetDetail AS ld ON li.InternetListID=ld.InternetListID WHERE li.BookingID=" + BookingId + "");
if (dtinternet.Rows.Count > 0)
{
for (int it = 0; it < dtinternet.Rows.Count; it++)
{
DataRow it_dr = all_invoice.DTAllInterTele.NewRow();
it_dr["ITInvoiceId"] = dtinternet.Rows[0]["InternetListID"];
it_dr["ITServiceDate"] = dtinternet.Rows[it]["CurrentDate"];
it_dr["ITRoomNo"] = dtinternet.Rows[it]["RoomNo"];
it_dr["ITItemName"] = dtinternet.Rows[it]["IItemName"];
it_dr["ITHour"] = dtinternet.Rows[it]["IQuantity"];
it_dr["ITRate"] = dtinternet.Rows[it]["IRate"];
it_dr["ITTotal"] = dtinternet.Rows[it]["TotalAmount"];
all_invoice.DTAllInterTele.Rows.Add(it_dr);
}
}
else
{
//DataRow it_dr = all_invoice.DTAllInterTele.NewRow();
//it_dr["ITInvoiceId"] = "Nill";
//it_dr["ITServiceDate"] = "Nill";
//it_dr["ITRoomNo"] = "Nill";
//it_dr["ITItemName"] = "Nill";
//it_dr["ITHour"] = Convert.ToInt32(0);
//it_dr["ITRate"] = Convert.ToDecimal(0);
//it_dr["ITTotal"] = Convert.ToDecimal(0);
//all_invoice.DTAllInterTele.Rows.Add(it_dr);
}
if (dtt.Rows.Count > 0)
{
for (int i = 0; i < dtt.Rows.Count; i++)
{
List objhotel = new List();
dthotel = objhotel.queryList("select HotelName,Address,City,Currencies,tblcountry.countryname,tblstate.statename from tblHotelDetails h left join tblcountry on tblcountry.countryid=h.countryid left join tblstate on tblstate.stateid=h.stateid where HotelID= '" + hotelid + "'");
DataRow dr = all_invoice.DTAllInvoice.NewRow();
dr["HotelName"] = dthotel.Rows[0]["HotelName"];
dr["HAddress"] = dthotel.Rows[0]["Address"];
dr["HCity"] = dthotel.Rows[0]["City"];
dr["HState"] = dthotel.Rows[0]["statename"];
dr["HCountry"] = dthotel.Rows[0]["countryname"];
dr["InvoiceId"] = Convert.ToInt32(InvoiceId);
dr["BookingId"] = dtt.Rows[0]["BookingID"];
dr["CheckOutDate"] = dtt.Rows[0]["CheckOutDate"];
dr["CheckInDate"] = dtt.Rows[0]["CheckInDate"];
dr["RoomNo"] = dtroom.Rows[0]["RoomNo"];
//List lsroom = new List();
//DataTable dtroom = lsroom.queryList("SELECT R.RoomNo FROM tblBookingDetail AS BD INNER JOIN tblRoom AS R ON BD.RoomID = R.RoomID WHERE BD.BookingID = '" + BookingId + "'");
for (int r = 1; r < dtroom.Rows.Count; r++)
{
dr["RoomNo"] = dr["RoomNo"] + ", " + dtroom.Rows[r]["RoomNo"];
}
dr["RoomAmt"] = dtt.Rows[0]["RoomTotal"];
dr["AdvanceAmt"] = dtt.Rows[0]["Advance"];
dr["RoomServicesAmt"] = dtt.Rows[0]["RoomServices"];
dr["LaundryAmt"] = dtt.Rows[0]["LaundryServices"];
dr["Inter-teleAmt"] = dtt.Rows[0]["InternetServices"];
dr["Tours-TravAmt"] = dtt.Rows[0]["ToorsServices"];
dr["CustAddress"] = dtt.Rows[0]["Address"];
dr["CustName"] = dtt.Rows[0]["CustomerName"];
dr["CustMobile"] = dtt.Rows[0]["MobileNo"];
dr["CustEmail"] = dtt.Rows[0]["EmailId"];
dr["CustCompanyName"] = dtt.Rows[0]["CompanyName"];
dr["extraamt"] = dtt.Rows[0]["AddextaCharges"];
dr["deductamt"] = dtt.Rows[0]["DeductCharges"];
all_invoice.DTAllInvoice.Rows.Add(dr);
}
}
rd.SetDataSource(all_invoice);
rd.OpenSubreport("RS_All_Invoice_Room.rpt").SetDataSource(all_invoice);
rd.OpenSubreport("LD_All_Invoice_Room.rpt").SetDataSource(all_invoice);
rd.OpenSubreport("IT_All_Invoice_Room.rpt").SetDataSource(all_invoice);
rd.OpenSubreport("TT_All_Invoice_Room.rpt").SetDataSource(all_invoice);
TextObject txtadamtr = (TextObject)rd.ReportDefinition.ReportObjects["txtadamt"];
TextObject txtpendingamtr = (TextObject)rd.ReportDefinition.ReportObjects["txtpendingamt"];
TextObject txtextrachrgr = (TextObject)rd.ReportDefinition.ReportObjects["txtexchrg"];
TextObject txtdeductamtr = (TextObject)rd.ReportDefinition.ReportObjects["txtdeductamt"];
TextObject txtrsgtotalr = (TextObject)rd.OpenSubreport("RS_All_Invoice_Room.rpt").ReportDefinition.ReportObjects["txtrsgtotal"];
TextObject txtldgtotalr = (TextObject)rd.OpenSubreport("LD_All_Invoice_Room.rpt").ReportDefinition.ReportObjects["txtldgtotal"];
TextObject txtitgtotalr = (TextObject)rd.OpenSubreport("IT_All_Invoice_Room.rpt").ReportDefinition.ReportObjects["txtitgtotal"];
TextObject txtttgtotalr = (TextObject)rd.OpenSubreport("TT_All_Invoice_Room.rpt").ReportDefinition.ReportObjects["txtttgtotal"];
txtadamtr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtpendingamtr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtextrachrgr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtdeductamtr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtrsgtotalr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtldgtotalr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtitgtotalr.Text = dthotel.Rows[0]["Currencies"].ToString();
txtttgtotalr.Text = dthotel.Rows[0]["Currencies"].ToString();
string Invoice_Folder = "Invoice_PDF";
string ModuleName = "RoomManagement";
string old =hotelid.ToString();
bool isexist = System.IO.Directory.Exists(Server.MapPath("~/") + "\\" + Invoice_Folder + "\\" + old + "\\" + ModuleName);
if (!isexist)
{
Directory.CreateDirectory(Server.MapPath("~/") + "\\" + Invoice_Folder + "\\" + old + "\\" + ModuleName);
}
PdfName = InvoiceId.ToString() + "FinalInvoice" + "_" + DateTime.Today.ToString("MM-dd-yyyy") + ".pdf";
rd.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("~/") + "\\" + Invoice_Folder + "\\" + old + "\\" + ModuleName + "\\" + PdfName);
List lstpdf = new List();
lstpdf.queryList("Update tblinvoice Set InvoiceImage='" + PdfName.ToString() + "' where InvoiceID=" + InvoiceId + " and HotelID=" + hotelid + "");
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
No comments:
Post a Comment