i check the above link but i think that is not useful for me
beacause i am creating the pdf files with the code of itextsharp pdf in asp.net c#.
my code works fine but pdf Open in Same Tab of browser
I want to Show pdf in new tab of browser on the click of button.
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="SalesBill.aspx.cs" Inherits="SalesBill" %>
<%@ Register TagPrefix="cc1" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style>
.form-horizontal .control-label {
padding-top: 7px;
margin-bottom: 0;
text-align: left;
}
.list-group-item {
color: Maroon;
border: 1px solid #fff;
}
</style>
<script src="jquery-1.8.2.js"></script>
<%-- <script type="text/javascript">
function onlyNumbersWithDot(e) {
var charCode;
if (e.keyCode > 0) {
charCode = e.which || e.keyCode;
}
else if (typeof (e.charCode) != "undefined") {
charCode = e.which || e.keyCode;
}
if (charCode == 46)
return true
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<script type="text/javascript">
function ShowPopup() {
$("#btnShowPopup").click();
}
</script>
<script type="text/javascript">
function KeyPress(e) {
var evtobj = window.event ? event : e
//Do action on Alt + A
if (evtobj.keyCode == 65 && evtobj.altKey)// its checks the alt+A Is press
{
__doPostBack("<%= btnSaveBill.UniqueID %>", "");//alert(" Alter Alt +A Press");//Msg Display Properly
}
//Do action on SHIFT + DELEETE
if (evtobj.keyCode == 46 && evtobj.shiftKey) {
alert("Shift + Delete Pressed");
}
}
document.onkeydown = KeyPress;
</script>--%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:UpdatePanel ID="upCrudGrid" runat="server">
<ContentTemplate>
<div class="panel panel-info" id="EstbApprovalPanel" runat="server">
<div class="panel-heading">Sales Bill </div>
<div class="panel-body">
<%--<div class="form-horizontal">--%>
<div class="form-horizontal">
<div class="form-group">
<asp:Label ID="lblBill" runat="server" Text="Bill No" CssClass="control-label col-lg-1 col-md-1"></asp:Label>
<div class="col-md-2 col-lg-2">
<asp:TextBox ID="txtBill" runat="server" CssClass="form-control input-sm" Enabled="true"></asp:TextBox>
</div>
<asp:Label ID="lblDate" runat="server" Text="Date" CssClass="control-label col-lg-1 col-md-1"></asp:Label>
<div class="col-md-2 col-lg-2">
<div class="input-group ">
<asp:TextBox ID="txtDate" runat="server" TextMode="SingleLine" Font-Size="14px" CssClass="form-control input-sm" data-toggle="tooltip" data-placement="bottom" title="Enter Date"></asp:TextBox>
<span class="input-group-btn">
<asp:LinkButton ID="btnPopDate" runat="server" CssClass="btn btn-primary btn-block Custbtn btn-sm" BorderStyle="Solid">
<span aria-hidden="true" class="fa fa-calendar"></span>
</asp:LinkButton>
<cc1:CalendarExtender ID="CalExtBill" runat="server" PopupButtonID="btnPopDate" TargetControlID="txtDate" Format="dd/MM/yyyy" PopupPosition="BottomRight"></cc1:CalendarExtender>
</span>
</div>
</div>
<asp:Label ID="lblName" runat="server" Text="Party" CssClass="control-label col-md-1 col-lg-1"></asp:Label>
<div class="col-md-4 col-lg-4">
<asp:DropDownList ID="drpCustName" runat="server" CssClass="form-control input-sm" AutoPostBack="true"></asp:DropDownList>
</div>
<div class="col-md-1 col-lg-1">
<asp:LinkButton ID="btnAddCust" runat="server" CssClass="btn btn-primary btn-block btn-sm" OnClick="btnAddCust_Click"><span class="fa fa-plus"></span></asp:LinkButton>
</div>
</div>
</div>
<br />
<asp:Label ID="lblTime" runat="server" />
<div>
<div class="table-responsive">
<asp:GridView ID="gridSaleDetails" runat="server" CssClass="table table-condensed table-striped" AutoGenerateColumns="false" ViewStateMode="Enabled" HeaderStyle-CssClass="bg-info"
EmptyDataText="No Products has been added.">
<Columns>
<asp:TemplateField HeaderText="Product" HeaderStyle-Width="25%">
<ItemTemplate>
<asp:Label ID="lblProductGrid" runat="server" Text='<%#Eval("Product") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Price" HeaderStyle-Width="11%">
<ItemTemplate>
<asp:Label ID="lblPriceGrid" runat="server" Text='<%#Eval("Price") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" HeaderStyle-Width="11%">
<ItemTemplate>
<asp:Label ID="lblQuantityGrid" runat="server" Text='<%#Eval("Quantity") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Box" HeaderStyle-Width="11%">
<ItemTemplate>
<asp:Label ID="lblBoxGrid" runat="server" Text='<%#Eval("Box") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Pcs Per Box" HeaderStyle-Width="11%">
<ItemTemplate>
<asp:Label ID="lblPcsPerBoxGrid" runat="server" Text='<%#Eval("PcsPerBox") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount" HeaderStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblTotal" runat="server" Text='<%#Eval("Amount") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Remove" HeaderStyle-Width="5%">
<ItemTemplate>
<asp:LinkButton ID="lnkRemove" runat="server" OnClick="lnkRemove_Click"><span style="font-size:medium;color:red" class="glyphicon glyphicon-trash"></span></asp:LinkButton><%--<i class="fa fa-trash fa-2x"></i>--%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
<div class="form-group col-md-3 col-lg-3">
<asp:Label ID="lblProduct" runat="server" Text="Product" CssClass="control-label"></asp:Label>
<asp:TextBox ID="txtProduct" runat="server" CssClass="form-control input-sm" AutoPostBack="true" OnTextChanged="txtProduct_TextChanged"></asp:TextBox>
<div id="divwidth"></div>
<cc1:AutoCompleteExtender ServiceMethod="SearchProduct"
MinimumPrefixLength="2"
CompletionInterval="0" EnableCaching="false" CompletionSetCount="10"
TargetControlID="txtProduct"
ID="AutoCompleteExtender2" runat="server" FirstRowSelected="false" CompletionListCssClass="AutoExtender"
CompletionListItemCssClass="list-group-item list-group-item-info input-sm"
CompletionListHighlightedItemCssClass="list-group-item active input-sm"
CompletionListElementID="divwidth">
</cc1:AutoCompleteExtender>
</div>
<div class="form-group col-md-1 col-lg-1">
<asp:Label ID="lblPrice" runat="server" Text="Price" CssClass="control-label"></asp:Label>
<asp:TextBox ID="txtPrice" runat="server" CssClass="form-control input-sm" Enabled="false" AutoPostBack="true" ></asp:TextBox>
</div>
<div class="form-group col-md-1 col-lg-1">
<asp:Label ID="lblQty" runat="server" Text="Quantity" CssClass="control-label "></asp:Label>
<asp:TextBox ID="txtQuantity" runat="server" CssClass="form-control input-sm input-sm" onkeypress="return onlyNumbersWithDot(event);" data-toggle="tooltip" data-placement="bottom" title="Enter Qty" OnTextChanged="txtQuantity_TextChanged" AutoPostBack="true"></asp:TextBox>
</div>
<div class="form-group col-md-1 col-lg-1">
<asp:Label ID="lblBox" runat="server" Text="Box" CssClass="control-label"></asp:Label>
<asp:TextBox ID="txtBox" runat="server" CssClass="form-control input-sm" data-toggle="tooltip" data-placement="bottom" title="Enter Box"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server" TargetControlID="txtBox" FilterType="Numbers" />
</div>
<div class="form-group col-md-1 col-lg-1">
<asp:Label ID="lblBoxPcs" runat="server" Text="Pcs" CssClass="control-label "></asp:Label>
<asp:TextBox ID="txtBoxPcs" runat="server" CssClass="form-control input-sm input-sm" data-toggle="tooltip" data-placement="bottom" title="Per Box"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="txtBoxPcs" FilterType="Numbers" />
</div>
<div class="form-group col-md-2 col-lg-2">
<asp:Label ID="lblAmt" runat="server" Text="Amount" CssClass="control-label"></asp:Label>
<asp:TextBox ID="txtAmt" runat="server" CssClass="form-control input-sm" Enabled="false"></asp:TextBox>
</div>
<div class="form-group col-md-2 col-lg-2">
<asp:Label ID="Label1" runat="server" Text="Amount" CssClass="control-label" Style="color: transparent"></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="form-control btn btn-warning btn-block btn-sm" OnClick="Insert" ForeColor="Black"><span class="glyphicon glyphicon-shopping-cart"></span> Add to Cart</asp:LinkButton><%--<i class="fa fa-cart-arrow-down "></i>--%>
</div>
<div class="form-group col-md-1 col-lg-1">
<asp:Label ID="Label2" runat="server" Text="Amount" CssClass="control-label" Style="color: transparent"></asp:Label>
<asp:LinkButton ID="btnClear" runat="server" CssClass="btn btn-default btn-block" OnClick="btnClear_Click"><span class="glyphicon glyphicon-repeat"></span></asp:LinkButton>
</div>
<div class="form-horizontal">
<div class="form-group">
<div class="col-md-offset-3 col-lg-offset-3 col-md-4 col-lg-4" id="alertdiv" runat="server" visible="false">
<%-- <div class="alert alert-danger" role="alert">--%>
<asp:Label ID="lblalertQty" runat="server" Text="" CssClass="control-label text-danger"></asp:Label>
<%--</div>--%>
<%-- <div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label><%--<a href="#" class="alert-link">Alert Link</a>
</div>--%>
</div>
</div>
</div>
<div class="form-horizontal">
<div class="form-group">
<asp:Label ID="lblPaidAmt" runat="server" Text="Paid Amount" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-4 col-md-4">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-inr"></i></span>
<asp:TextBox ID="txtPaidAmt" runat="server" CssClass="form-control input-sm" AutoPostBack="true" OnTextChanged="txtPaidAmt_TextChanged" data-toggle="tooltip" data-placement="bottom" title="Enter Paid Amount"></asp:TextBox>
<span class="input-group-addon">.00</span>
<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="txtPaidAmt" FilterType="Numbers" />
</div>
</div>
<asp:Label ID="lblSubTotal" runat="server" Text="Sub Total" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-4 col-md-4">
<asp:TextBox ID="txtSubTotal" runat="server" CssClass="form-control input-sm" AutoPostBack="true" OnTextChanged="txtSubTotal_TextChanged"></asp:TextBox>
</div>
</div>
<div class="form-group">
<asp:Label ID="lblDueAmt" runat="server" Text="Due Amount" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-4 col-md-4">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-inr"></i></span>
<asp:TextBox ID="txtDueAmt" runat="server" CssClass="form-control input-sm" Enabled="false"></asp:TextBox>
<span class="input-group-addon">.00</span>
</div>
</div>
<asp:Label ID="lblDiscount" runat="server" Text="Discount" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-2 col-md-2">
<div class="input-group">
<asp:TextBox ID="txtDiscountRate" runat="server" CssClass="form-control input-sm" AutoPostBack="true" OnTextChanged="txtDiscountRate_TextChanged" Placeholder="Enter Rate" data-toggle="tooltip" data-placement="bottom" title="Enter Discount Rate"></asp:TextBox><span class="input-group-addon"><i class="fa fa-tags"></i></span>
</div>
</div>
<div class="col-lg-2 col-md-2">
<asp:TextBox ID="txtDiscAmt" runat="server" CssClass="form-control input-sm" Enabled="false"></asp:TextBox>
</div>
</div>
<div class="form-group">
<asp:Label ID="lblPayType" runat="server" Text="Payment Type" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-4 col-md-4">
<asp:DropDownList ID="drpPayType" runat="server" CssClass="form-control input-sm">
<asp:ListItem Value="0" Text="Please Select"></asp:ListItem>
<asp:ListItem Value="1" Text="Cash"></asp:ListItem>
<asp:ListItem Value="2" Text="Cheque"></asp:ListItem>
</asp:DropDownList>
</div>
<asp:Label ID="lblTotAmt" runat="server" Text="Total Amount" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-4 col-md-4">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-inr"></i></span>
<asp:TextBox ID="txtTotAmt" runat="server" CssClass="form-control input-sm" Enabled="false"></asp:TextBox>
<span class="input-group-addon">.00</span>
</div>
</div>
</div>
<div class="form-group">
<asp:Label ID="lblPAyStatus" runat="server" Text="Payment Status" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-4 col-md-4">
<asp:DropDownList ID="drpPayStatus" runat="server" CssClass="form-control input-sm">
<asp:ListItem Value="0" Text="Please Select"></asp:ListItem>
<asp:ListItem Value="1" Text="Complete"></asp:ListItem>
<asp:ListItem Value="2" Text="Advance"></asp:ListItem>
<asp:ListItem Value="3" Text="Half"></asp:ListItem>
</asp:DropDownList>
</div>
<asp:Label ID="lblVat" runat="server" Text="VAT %" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-2 col-md-2">
<div class="input-group">
<asp:TextBox ID="txtVatRate" runat="server" CssClass="form-control input-sm" AutoPostBack="true"></asp:TextBox>
<span class="input-group-addon"><i class="fa fa-percent"></i></span>
</div>
</div>
<div class="col-lg-2 col-md-2">
<asp:TextBox ID="txtVatAmt" runat="server" CssClass="form-control input-sm" Enabled="false"></asp:TextBox>
</div>
</div>
<div class="form-group">
<div class="col-md-3 col-lg-3">
<asp:LinkButton ID="btnSaveBill" runat="server" CssClass="form-control btn btn-success btn-block" OnClick="btnSaveBill_Click"><span class="glyphicon glyphicon-save"></span> Save Bill</asp:LinkButton>
</div>
<div class=" col-md-3 col-lg-3">
<asp:LinkButton ID="LinkButton2" runat="server" CssClass="btn btn-default btn-block" OnClick="LinkButton2_Click"><span class="glyphicon glyphicon-repeat"></span> Reset</asp:LinkButton>
</div>
<asp:Label ID="lblGrandTotal" runat="server" Text="Grand Total" CssClass="control-label col-lg-2 col-md-2"></asp:Label>
<div class="col-lg-4 col-md-4">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-inr"></i></span>
<asp:TextBox ID="txtGrandTotal" runat="server" CssClass="form-control input-sm" Enabled="false"></asp:TextBox>
<span class="input-group-addon">.00</span>
</div>
</div>
</div>
</div>
<%-- </div>--%>
<asp:LinkButton ID="lnkFakeAlert" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="mpeMessageAlert" runat="server" PopupControlID="pnlMessageAlert"
TargetControlID="lnkFakeAlert" BehaviorID="mpeMessageAlert" CancelControlID="btnCloseAlert"
BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlMessageAlert" runat="server" Style="display: none;">
<div class="alert alert-success" role="alert">
<asp:LinkButton ID="btnCloseAlert" runat="server" CssClass="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></asp:LinkButton>
<span class=" glyphicon glyphicon-ok"></span> <strong>Alert!</strong>
<asp:Label ID="lblPopMsg" runat="server" Text=""></asp:Label>
</div>
</asp:Panel>
</div>
</div>
<asp:Button ID="btnPrintSailsBill" runat="server" Text="Print Bill WithOut Border" CssClass="btn-info" OnClick="btnPrintSailsBill_Click" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnPrintSailsBill"/>
<asp:PostBackTrigger ControlID="btnPrint"/>
</Triggers>
</asp:UpdatePanel>
<%--<asp:Button ID="btnPrintSailsBill" runat="server" Text="Print Bill WithOut Border" CssClass="btn-info" OnClick="btnPrintSailsBill_Click" />
<asp:Button ID="btnPrint" runat="server" Text="PrintBill WithBorder" CssClass="btn-info" OnClick="btnPrint_Click"/>--%>
<asp:LinkButton ID="btnShowPopup" Style="display: none;" CssClass="btn btn-primary btn-lg" runat="server" data-toggle="modal" data-target="#myModal">
Launch demo modal
</asp:LinkButton>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<asp:LinkButton ID="LinkButton3" runat="server" Visible="false" >LinkButton</asp:LinkButton>
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title">Registration done Successfully</h4>
</div>
<div class="modal-body">
<asp:Label ID="lblMessage" runat="server" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close</button>
<button type="button" class="btn btn-primary">
Save changes</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<asp:Button ID="btnPrint" runat="server" Text="PrintBill WithBorder" CssClass="btn-info" Visible="false" OnClick="btnPrint_Click"/>
<script>
function pageLoad() {
$('[data-toggle="tooltip"]').tooltip()
}
</script>
</asp:Content>
using iTextSharp.text;
using iTextSharp.text.pdf;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SalesBill : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["InventoryDB"].ConnectionString);
string BillNumber = string.Empty;
string BillDate = string.Empty;
string PartyName = string.Empty;
int SrNo = 0;
string ProductName = string.Empty;
string ProductRate = string.Empty;
string ProductQuantity = string.Empty;
string ProductNumberOfBox = string.Empty;
string ProductAmount = string.Empty;
string AmountInWords = string.Empty;
string DiscountRate = string.Empty;
string DiscountAmount = string.Empty;
string WithDicoount_TotalAmount = string.Empty;
string VatRate = string.Empty;
string VatAmount = string.Empty;
string ItemTotalAmount = string.Empty;
string WithVat_GrandTotal = string.Empty;
string TotalQuantity = string.Empty;
string TotalBoxes = string.Empty;
string BuyersVatTinNo = string.Empty;
string BuyersCstTinNo = string.Empty;
string SellerVatTinNo = string.Empty;
string SellerCstTinNo = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CalExtBill.SelectedDate = System.DateTime.Now.Date; // set current date
GenerateBillNumber();
BindCustomerName();
GetVatRate();
try
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[6] { new DataColumn("Product"), new DataColumn("Price"), new DataColumn("Quantity"), new DataColumn("Box"), new DataColumn("PcsPerBox"), new DataColumn("Amount") });
ViewState["ProductDetails"] = dt;
this.BindGrid();
txtSubTotal.Enabled = false;
}
catch (Exception ex)
{
lblPopMsg.Text = "Error occurred : " + ex.ToString();
mpeMessageAlert.Show();
}
}
}
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> SearchProduct(string prefixText, int count)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["InventoryDB"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select Name from MstProduct where " +
"Name like @SearchText + '%'";
// cmd.CommandText = "select Name from MstProduct where " +
//"Name like @SearchText + '%'";
cmd.Parameters.AddWithValue("@SearchText", prefixText);
cmd.Connection = conn;
conn.Open();
List<string> Products = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
Products.Add(sdr["Name"].ToString());
}
}
conn.Close();
if (Products.Count == 0)
{
Products.Add("No Match Found.");
}
return Products;
}
}
}
protected void txtProduct_TextChanged(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager
.ConnectionStrings["InventoryDB"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
//cmd.CommandText = "select ID from MstProduct where " +
//"Name like @SearchText + '%'";
cmd.CommandText = "Select Price from MstProduct where Name='" + txtProduct.Text + "'";
cmd.Connection = conn;
conn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
txtPrice.Text = (sdr["Price"].ToString());
}
}
conn.Close();
if (txtProduct.Text == "")
{
txtPrice.Text = "";
txtQuantity.Text = "";
txtBox.Text = "";
txtBoxPcs.Text = "";
txtAmt.Text = "";
}
// return customers;
}
}
}
public void GenerateBillNumber()
{
try
{
int AID = 0;
int lastID = 0;
string sql = "select ID from SalesForm";
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
AID = Convert.ToInt32(dr["ID"]);
}
con.Close();
if (AID != 0)
{
String query11 = "SELECT MAX(ID) as 'LastID' FROM SalesForm";
con.Open();
SqlCommand cmdid = new SqlCommand(query11, con);
lastID = int.Parse(cmdid.ExecuteScalar().ToString()) + 1;
txtBill.Text = lastID.ToString();
con.Close();
}
else
{
txtBill.Text = (lastID + 1).ToString();
}
}
catch (Exception)
{
}
}
protected void BindCustomerName()
{
SqlCommand cmd = new SqlCommand("select * from MstCustomer", con);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
drpCustName.DataSource = ds;
drpCustName.DataTextField = "FirmName";
drpCustName.DataValueField = "ID";
drpCustName.DataBind();
drpCustName.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select Customer--", "0"));
}
protected void GetVatRate()
{
try
{
string queryGetVatRate = "Select * from MstVat ";
SqlCommand cmdGetVatRate = new SqlCommand(queryGetVatRate, con);
con.Open();
SqlDataReader drGetVatRate = cmdGetVatRate.ExecuteReader();
if (drGetVatRate.Read())
{
string VatRate = Convert.ToDecimal(drGetVatRate["Name"]).ToString();
txtVatRate.Text = VatRate;
txtVatRate.Enabled = false;
con.Close();
}
}
catch (Exception)
{
lblPopMsg.Text = "Error Occured !!";
mpeMessageAlert.Show();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
}
protected void ClearAll()
{
txtDate.Text = "";
drpCustName.SelectedIndex = 0;
txtSubTotal.Text = "";
txtDiscountRate.Text = "";
txtDiscAmt.Text = "";
txtTotAmt.Text = "";
txtVatAmt.Text = "";
txtDueAmt.Text = "";
txtGrandTotal.Text = "";
txtPaidAmt.Text = "";
drpPayStatus.SelectedIndex = 0;
drpPayType.SelectedIndex = 0;
}
protected void BindGrid()
{
gridSaleDetails.DataSource = (DataTable)ViewState["ProductDetails"];
gridSaleDetails.DataBind();
}
protected void Insert(object sender, EventArgs e)
{
DataTable dt = (DataTable)ViewState["ProductDetails"];
dt.Rows.Add(txtProduct.Text, txtPrice.Text.Trim(), txtQuantity.Text.Trim(), txtBox.Text.Trim(), txtBoxPcs.Text.Trim(), txtAmt.Text.Trim());
ViewState["ProductDetails"] = dt;
this.BindGrid();
txtProduct.Text = "";
txtPrice.Text = "";
txtQuantity.Text = "";
txtBox.Text = "";
txtBoxPcs.Text = string.Empty;
txtQuantity.Text = string.Empty;
txtAmt.Text = "";
GrandTotal();
txtDiscountRate.Focus();
}
protected void txtQuantity_TextChanged(object sender, EventArgs e)
{
if (txtQuantity.Text == "")
{
txtAmt.Text = "";
txtBox.Text = "";
txtBoxPcs.Text = "";
txtBox.Focus();
}
else
{
if (txtPrice.Text == "")
{
}
else
{
int TotalAmount = (int.Parse(txtQuantity.Text) * int.Parse(txtPrice.Text));
txtAmt.Text = TotalAmount.ToString();
lblalertQty.Text = "Quantity Short!!";
alertdiv.Visible = true;
txtBox.Focus();
}
}
}
protected void lnkRemove_Click(object sender, EventArgs e)
{
LinkButton lb = (LinkButton)sender;
GridViewRow gvRow = (GridViewRow)lb.NamingContainer;
int rowID = gvRow.RowIndex;
if (ViewState["ProductDetails"] != null)
{
DataTable dt = (DataTable)ViewState["ProductDetails"];
if (dt.Rows.Count > 0)
{
if (gvRow.RowIndex < dt.Rows.Count)
{
//Remove the Selected Row data
dt.Rows.Remove(dt.Rows[rowID]);
}
}
//Store the current data in ViewState for future reference
ViewState["ProductDetails"] = dt;
//Re bind the GridView for the updated data
gridSaleDetails.DataSource = dt;
gridSaleDetails.DataBind();
GrandTotal();
}
DataTable dt1 = (DataTable)ViewState["ProductDetails"];
if (dt1.Rows.Count == 0)
{
if (gvRow.RowIndex == dt1.Rows.Count)
{
txtSubTotal.Text = "";
txtDiscountRate.Text = "";
txtDiscAmt.Text = "";
txtTotAmt.Text = "";
txtVatRate.Text = "";
txtVatAmt.Text = "";
txtDueAmt.Text = "";
txtGrandTotal.Text = "";
txtPaidAmt.Text = "";
drpPayStatus.SelectedIndex = 0;
drpPayType.SelectedIndex = 0;
}
}
}
private void GrandTotal()
{
float GTotal = 0f;
for (int i = 0; i < gridSaleDetails.Rows.Count; i++)
{
String total = (gridSaleDetails.Rows[i].FindControl("lblTotal") as Label).Text;
GTotal += Convert.ToSingle(total);
}
txtSubTotal.Text = GTotal.ToString();
if (txtDiscountRate.Text == "")
{
txtTotAmt.Text = txtSubTotal.Text;
if (txtVatRate.Text == "")
{
txtGrandTotal.Text = txtTotAmt.Text;
txtDueAmt.Text = txtGrandTotal.Text;
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
else
{
float VatAmount = (Convert.ToInt32(txtTotAmt.Text) * Convert.ToInt32(txtVatRate.Text)) / 100;
txtVatAmt.Text = Convert.ToString(VatAmount);
txtGrandTotal.Text = Convert.ToDouble(Convert.ToInt32(txtTotAmt.Text) + VatAmount).ToString();
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
}
else
{
float discountTotalAmtValue = (Convert.ToInt32(txtSubTotal.Text) * Convert.ToInt32(txtDiscountRate.Text)) / 100;
txtDiscAmt.Text = Convert.ToString(discountTotalAmtValue);
txtTotAmt.Text = Convert.ToDouble(Convert.ToInt32(txtSubTotal.Text) - discountTotalAmtValue).ToString();
if (txtVatRate.Text == "")
{
txtGrandTotal.Text = txtTotAmt.Text;
txtDueAmt.Text = txtGrandTotal.Text;
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
else
{
float VatAmount = (Convert.ToInt32(txtTotAmt.Text) * Convert.ToInt32(txtVatRate.Text)) / 100;
txtVatAmt.Text = Convert.ToString(VatAmount);
txtGrandTotal.Text = Convert.ToDouble(Convert.ToInt32(txtTotAmt.Text) + VatAmount).ToString();
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
}
if (txtVatRate.Text == "")
{
txtVatAmt.Text = "";
txtGrandTotal.Text = txtTotAmt.Text;
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
else
{
float VatAmount = (Convert.ToInt32(txtTotAmt.Text) * Convert.ToInt32(txtVatRate.Text)) / 100;
txtVatAmt.Text = Convert.ToString(VatAmount);
txtGrandTotal.Text = Convert.ToDouble(Convert.ToInt32(txtTotAmt.Text) + VatAmount).ToString();
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
if (gridSaleDetails.Rows.Count == 0)
{
txtSubTotal.Text = "";
}
}
private void DiscountCalculate()
{
if (txtDiscountRate.Text == "")
{
txtDiscAmt.Text = "";
txtTotAmt.Text = txtSubTotal.Text;
if (txtVatRate.Text == "")
{
txtGrandTotal.Text = txtTotAmt.Text;
txtDueAmt.Text = txtGrandTotal.Text;
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
else
{
float VatAmount = (Convert.ToInt32(txtTotAmt.Text) * Convert.ToInt32(txtVatRate.Text)) / 100;
txtVatAmt.Text = Convert.ToString(VatAmount);
txtGrandTotal.Text = Convert.ToDouble(Convert.ToInt32(txtTotAmt.Text) + VatAmount).ToString();
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
}
else
{
float discountTotalAmtValue = (Convert.ToInt32(txtSubTotal.Text) * Convert.ToInt32(txtDiscountRate.Text)) / 100;
txtDiscAmt.Text = Convert.ToString(discountTotalAmtValue);
txtTotAmt.Text = Convert.ToDouble(Convert.ToInt32(txtSubTotal.Text) - discountTotalAmtValue).ToString();
if (txtVatRate.Text == "")
{
txtGrandTotal.Text = txtTotAmt.Text;
txtDueAmt.Text = txtGrandTotal.Text;
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
else
{
float VatAmount = (Convert.ToInt32(txtTotAmt.Text) * Convert.ToInt32(txtVatRate.Text)) / 100;
txtVatAmt.Text = Convert.ToString(VatAmount);
txtGrandTotal.Text = Convert.ToDouble(Convert.ToInt32(txtTotAmt.Text) + VatAmount).ToString();
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
}
}
private void VatValueCalculate()
{
if (txtVatRate.Text == "")
{
txtVatAmt.Text = "";
txtGrandTotal.Text = txtTotAmt.Text;
//txtDueAmt.Text = txtGrandTotal.Text;
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
else
{
//Double VatAmount = (Convert.ToDouble(txtTotAmt.Text) * Convert.ToDouble(txtVatRate.Text)) / 100;
float VatAmount = (Convert.ToInt32(txtTotAmt.Text) * Convert.ToInt32(txtVatRate.Text)) / 100;
txtVatAmt.Text = Convert.ToString(VatAmount);
txtGrandTotal.Text = Convert.ToDouble(Convert.ToInt32(txtTotAmt.Text) + VatAmount).ToString();
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
}
}
protected void txtSubTotal_TextChanged(object sender, EventArgs e)
{
//if (txtSubTotal.Text == "")
{
//txtDiscAmt.Text = 0.ToString();
//txtVatAmt.Text = 0.ToString();
//txtGrandTotal.Text = 0.ToString();
//txtPaidAmt.Text = 0.ToString();
//txtDueAmt.Text = 0.ToString();
}
}
protected void txtDiscountRate_TextChanged(object sender, EventArgs e)
{
DiscountCalculate();
float VatAmount = (Convert.ToInt32(txtTotAmt.Text) * Convert.ToInt32(txtVatRate.Text)) / 100;
txtVatAmt.Text = Convert.ToString(VatAmount);
txtGrandTotal.Text = Convert.ToDouble(Convert.ToInt32(txtTotAmt.Text) + VatAmount).ToString();
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
}
else
{
float DueAmount = Convert.ToInt32(txtGrandTotal.Text) - Convert.ToInt32(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
}
//VatValueCalculate();
//int DiscountAmount = (int.Parse(txtSubTotal.Text) * int.Parse(txtDiscountRate.Text)/100);
//txtDiscAmt.Text = DiscountAmount.ToString();
}
protected void txtVatRate_TextChanged(object sender, EventArgs e)
{
VatValueCalculate();
txtPaidAmt.Focus();
}
protected void txtPaidAmt_TextChanged(object sender, EventArgs e)
{
if (txtPaidAmt.Text == "")
{
txtDueAmt.Text = txtGrandTotal.Text;
drpPayType.Focus();
}
else
{
if (txtGrandTotal.Text != "")
{
float DueAmount = Convert.ToInt64(txtGrandTotal.Text) - Convert.ToInt64(txtPaidAmt.Text);
txtDueAmt.Text = Convert.ToString(DueAmount);
drpPayType.Focus();
}
}
}
protected void SaveBill()
{
DateTime dt = new DateTime();
//dt = DateTime.ParseExact(this.txtDate.Text, "dd/MM/yyyy",null);
dt = DateTime.ParseExact(this.txtDate.Text, "dd/MM/yyyy", null);
string BillDate = dt.ToString();
string QueryBillForm = "Insert into SalesForm (DiscountRate,DiscountAmt,GrossAmt,VatRate,VatAmt,GrandTotal,PaidAmt,PayMode,PayStatus,Customer) values ('" + txtDiscountRate.Text + "','" + txtDiscAmt.Text + "','" + txtTotAmt.Text + "','" + txtVatRate.Text + "','" + txtVatAmt.Text + "','" + txtGrandTotal.Text + "','" + txtPaidAmt.Text + "','" + drpPayType.SelectedValue + "','" + drpPayStatus.SelectedValue + "','" + drpCustName.SelectedValue + "')";
SqlCommand cmdInsertBillForm = new SqlCommand(QueryBillForm, con);
con.Open();
cmdInsertBillForm.ExecuteNonQuery();
cmdInsertBillForm.Dispose();
con.Close();
//string QueryBillForm = "Insert into SalesForm (Date,DiscountRate,DiscountAmt,GrossAmt,VatRate,VatAmt,GrandTotal,PaidAmt,PayMode,PayStatus,Customer) values ('@Date','@DiscountRate','@DiscountAmt','@GrossAmt','@VatRate','@VatAmt','@GrandTotal','@PaidAmt','@PayMode','@PayStatus','@Customer')";
//SqlCommand cmdInsertBillForm = new SqlCommand(QueryBillForm, con);
//con.Open();
//cmdInsertBillForm.Parameters.AddWithValue("@Date", dt);
//cmdInsertBillForm.Parameters.AddWithValue("@DiscountRate",txtDiscountRate.Text);
//cmdInsertBillForm.Parameters.AddWithValue("@DiscountAmt", txtDiscAmt.Text);
//cmdInsertBillForm.Parameters.AddWithValue("@GrossAmt", txtTotAmt.Text);
//cmdInsertBillForm.Parameters.AddWithValue("@VatRate", txtVatRate.Text);
//cmdInsertBillForm.Parameters.AddWithValue("@VatAmt", txtVatAmt.Text);
//cmdInsertBillForm.Parameters.AddWithValue("@GrandTotal", txtGrandTotal.Text);
//cmdInsertBillForm.Parameters.AddWithValue("@PaidAmt", txtPaidAmt.Text);
//cmdInsertBillForm.Parameters.AddWithValue("@PayMode", drpPayType.SelectedValue);
//cmdInsertBillForm.Parameters.AddWithValue("@PayStatus", drpPayStatus.SelectedValue);
//cmdInsertBillForm.Parameters.AddWithValue("@Customer", drpCustName.SelectedValue);
// cmdInsertBillForm.ExecuteNonQuery();
//cmdInsertBillForm.Dispose();
//con.Close();
// Save Records in SalesDetails table
for (int i = 0; i < gridSaleDetails.Rows.Count; i++)
{
Label ProductName = (Label)gridSaleDetails.Rows[i].Cells[1].FindControl("lblProductGrid");
//Label ProductWeight = (Label)gridSaleDetails.Rows[i].Cells[2].FindControl("lblWeightGrid");
Label ProductPrice = (Label)gridSaleDetails.Rows[i].Cells[1].FindControl("lblPriceGrid");
Label ProductQnty = (Label)gridSaleDetails.Rows[i].Cells[1].FindControl("lblQuantityGrid");
Label Box = (Label)gridSaleDetails.Rows[i].Cells[1].FindControl("lblBoxGrid");
Label PcsBox = (Label)gridSaleDetails.Rows[i].Cells[1].FindControl("lblPcsPerBoxGrid");
Label ProductTotal = (Label)gridSaleDetails.Rows[i].Cells[1].FindControl("lblTotal");
con.Open();
SqlCommand cmdFindProductId = new SqlCommand("Select ID from MstProduct where Name='" + ProductName.Text + "'", con);
int _ProductID = Convert.ToInt32(cmdFindProductId.ExecuteScalar());
//SqlCommand cmdFindWeightId = new SqlCommand("Select ID from MstWeight where Name='" + ProductWeight.Text + "' and Product='" + _ProductID + "'", con);
//int _WeightID = Convert.ToInt32(cmdFindWeightId.ExecuteScalar());
SqlCommand cmdFindOldQty = new SqlCommand("Select Quantity from QuantityDetails where Product='" + _ProductID + "'", con);
int _OldQuantity = Convert.ToInt32(cmdFindOldQty.ExecuteScalar());
int newQty = _OldQuantity - Convert.ToInt32(ProductQnty.Text);
string QueryInsertInsertQty = "Update QuantityDetails set Quantity='" + newQty + "' where Product='" + _ProductID + "'";
SqlCommand cmdInsertQty = new SqlCommand(QueryInsertInsertQty, con);
cmdInsertQty.ExecuteNonQuery();
cmdInsertQty.Dispose();
String QueryInsertSalesDetails = "Insert into SalesDetails (Product,Price,Quantity,Box,PcsPerBox,Amount,SalesForm) values ('" + _ProductID + "','" + ProductPrice.Text + "','" + ProductQnty.Text + "','" + Box.Text + "','" + PcsBox.Text + "','" + ProductTotal.Text + "','" + txtBill.Text + "')";
SqlCommand cmdInsert = new SqlCommand(QueryInsertSalesDetails, con);
cmdInsert.ExecuteNonQuery();
cmdInsert.Dispose();
con.Close();
}
//ClearAll();
gridSaleDetails.DataSource = null;
gridSaleDetails.DataBind();
}
protected void btnSaveBill_Click(object sender, EventArgs e)
{
SaveBill();
lblPopMsg.Text = "Bill Saved !!!";
mpeMessageAlert.Show();
GenerateBillNumber();
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
ClearAll();
}
protected void btnAddCust_Click(object sender, EventArgs e)
{
}
protected void btnClear_Click(object sender, EventArgs e)
{
}
//protected void btnAdd_Click(object sender, EventArgs e)
//{
// System.Text.StringBuilder sb = new System.Text.StringBuilder();
// //sb.Append(@"<script type='text/javascript'>");
// //sb.Append("$('#addModal').modal('show');");
// //sb.Append(@"</script>");
// //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddShowModalScript", sb.ToString(), false);
// //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script>$('#addModal').modal('show');</script>", false);
//}
//protected void Button1_Click(object sender, EventArgs e)
//{
//}
public void FetchDataForBillPrint()
{
try
{
con.Open();
//SqlCommand cmdSelect = new SqlCommand("select s.ID as BillNo,s.Date as BillDate,s.DiscountRate as DiscountRate,s.DiscountAmt as DiscountAmount,s.GrossAmt as AmountGrossAmt,s.VatRate as VatRate,s.VatAmt as VatAmount,s.GrandTotal As GrandTotal,s.PaidAmt,s.PayMode,s.PayStatus,s.Customer,c.FirmName as PartyName,sd.Quantity as TotalQuantity,sd.Box,sd.Amount as Amount,c.VATTin as BuyersVatTinNo,c.CSTTin as BuyersCstTinNo from SalesForm s,MstCustomer c,SalesDetails sd where sd.SalesForm=s.ID and s.Customer=c.ID and s.ID=" + 19 + "", con);
SqlCommand cmdSelect = new SqlCommand("select s.ID as BillNumber,s.Date as BillDate,s.DiscountRate as DiscountRate,s.DiscountAmt as DiscountAmount,s.GrossAmt as TotalAmount,s.VatRate as VatRate,s.VatAmt as VatAmount,s.GrandTotal as GrandTotal,s.PaidAmt as PaidAmount,sd.Quantity,sd.Box,sd.PcsPerBox,sd.Price,sd.Amount,p.Name as ProductName,p.Price as ProductPrice,p.BoxQty,c.FirmName as PartyName,c.PersonName,c.VATTin as BuyersVatTinNo,c.CSTTin as BuyersCstTinNo,m.Name from SalesDetails sd inner join SalesForm s on s.ID=sd.SalesForm inner join MstProduct p on p.ID=sd.Product inner join MstCustomer c on c.ID=s.Customer inner join MstMainCategory m on m.ID=p.MainCategory where s.ID=19", con);
//SqlDataAdapter sda = new SqlDataAdapter();
//sda.SelectCommand = cmdSelect;
//DataTable dt =new DataTable ();
//sda.Fill(dt);
//for (int i = 0; i < dt.Rows.Count; i++)
//{
// // SrNo =i+1.ToString();
// ProductName =dt.Rows[i][14].ToString();
// ProductRate =dt.Rows[i][15].ToString();
// ProductQuantity =dt.Rows[i][09].ToString();
// ProductNumberOfBox = dt.Rows[i][11].ToString();
// ProductAmount = dt.Rows[i][13].ToString();
//}
SqlDataReader drSelect = cmdSelect.ExecuteReader();
if (drSelect.Read())
{
BillNumber = drSelect["BillNumber"].ToString();
BillDate = drSelect["BillDate"].ToString();
PartyName = drSelect["PartyName"].ToString();
//TotalQuantity = drSelect["TotalQuantity"].ToString();
ItemTotalAmount = drSelect["ItemTotalAmount"].ToString();
AmountInWords = drSelect["Amount"].ToString();
DiscountRate = drSelect["DiscountRate"].ToString();
DiscountAmount = drSelect["DiscountAmount"].ToString();
VatRate = drSelect["VatRate"].ToString();
VatAmount = drSelect["VatAmount"].ToString();
WithVat_GrandTotal = drSelect["GrandTotal"].ToString();
BuyersVatTinNo = drSelect["BuyersVatTinNo"].ToString();
BuyersCstTinNo = drSelect["BuyersCstTinNo"].ToString();
SellerVatTinNo = drSelect["VatAmount"].ToString();
SellerCstTinNo = drSelect["VatAmount"].ToString();
}
drSelect.Close();
con.Close();
}
catch (System.Exception)
{
throw;
}
}
public static string ConvertNumbertoWords(int number)
{
if (number == 0)
return "ZERO";
if (number < 0)
return "minus " + ConvertNumbertoWords(Math.Abs(number));
string words = " ";
if ((number / 1000000000) > 0)
{
words += ConvertNumbertoWords(number / 1000000000) + " Billion ";
number %= 1000000000;
}
if ((number / 10000000) > 0)
{
words += ConvertNumbertoWords(number / 10000000) + " Crore ";
number %= 10000000;
}
if ((number / 1000000) > 0)
{
words += ConvertNumbertoWords(number / 1000000) + " MILLION ";
number %= 1000000;
}
if ((number / 1000) > 0)
{
words += ConvertNumbertoWords(number / 1000) + " THOUSAND ";
number %= 1000;
}
if ((number / 100) > 0)
{
words += ConvertNumbertoWords(number / 100) + " HUNDRED ";
number %= 100;
}
if (number > 0)
{
if (words != " ")
words += "AND ";
var unitsMap = new[] { "ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN" };
var tensMap = new[] { "ZERO", "TEN", "TWENTY", "THIRTY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY" };
if (number < 20)
words += unitsMap[number];
else
{
words += tensMap[number / 10];
if ((number % 10) > 0)
words += " " + unitsMap[number % 10];
}
}
return words;
}
protected void btnTest_Click1(object sender, EventArgs e)
{
}
public void PrintBill_WithOutBorder()
{
con.Close();
con.Open();
//select s.ID as BillNumber,s.Date as BillDate,s.DiscountRate as DiscountRate,s.DiscountAmt as DiscountAmount,s.GrossAmt as TotalAmount,s.VatRate as VatRate,s.VatAmt as VatAmount,s.GrandTotal as GrandTotal,s.PaidAmt as PaidAmount,sd.Quantity,sd.Box,sd.PcsPerBox,sd.Price,sd.Amount,p.Name as ProductName,p.Price as ProductPrice,p.BoxQty,c.FirmName as PartyName,c.PersonName,c.VATTin as BuyersVatTinNo,c.CSTTin as BuyersCstTinNo,m.Name from SalesDetails sd inner join SalesForm s on s.ID=sd.SalesForm inner join MstProduct p on p.ID=sd.Product inner join MstCustomer c on c.ID=s.Customer inner join MstMainCategory m on m.ID=p.MainCategory where s.ID=19
SqlCommand cmdSelect = new SqlCommand("select distinct s.ID as BillNumber,s.Date as BillDate,((select sum(sd.Amount) from SalesDetails sd where sd.SalesForm=" + txtBill.Text + ")) as ItemTotalAmount ,s.DiscountRate as DiscountRate,s.DiscountAmt as DiscountAmount,s.GrossAmt as WithDicoount_TotalAmount,s.VatRate as VatRate,s.VatAmt as VatAmount,s.GrandTotal as WithVat_GrandTotal,s.PaidAmt as PaidAmount,((select sum(sd.Quantity) from SalesDetails sd where sd.SalesForm=" + txtBill.Text + ")) as TotalQuantity ,((select sum(sd.Box) from SalesDetails sd where sd.SalesForm=" + txtBill.Text + ")) as TotalBox ,c.FirmName as PartyName,c.VATTin as BuyersVatTinNo,c.CSTTin as BuyersCstTinNo from SalesDetails sd inner join SalesForm s on s.ID=sd.SalesForm inner join MstProduct p on p.ID=sd.Product inner join MstCustomer c on c.ID=s.Customer where s.ID=" + txtBill.Text + "", con);//" + txtBill.Text + "
SqlDataReader drSelect = cmdSelect.ExecuteReader();
if (drSelect.Read())
{
BillNumber = drSelect["BillNumber"].ToString();
BillDate = drSelect["BillDate"].ToString();
PartyName = drSelect["PartyName"].ToString();
//TotalQuantity = drSelect["TotalQuantity"].ToString();
ItemTotalAmount = drSelect["ItemTotalAmount"].ToString();
//AmountInWords = "Wait".ToString();
DiscountRate = drSelect["DiscountRate"].ToString();
DiscountAmount = drSelect["DiscountAmount"].ToString();
WithDicoount_TotalAmount = drSelect["WithDicoount_TotalAmount"].ToString();
VatRate = drSelect["VatRate"].ToString();
VatAmount = drSelect["VatAmount"].ToString();
WithVat_GrandTotal = drSelect["WithVat_GrandTotal"].ToString();
string word = ConvertNumbertoWords(Convert.ToInt32(WithVat_GrandTotal));
AmountInWords = word;
TotalQuantity = drSelect["TotalQuantity"].ToString();
TotalBoxes = drSelect["TotalBox"].ToString();
BuyersVatTinNo = drSelect["BuyersVatTinNo"].ToString();
BuyersCstTinNo = drSelect["BuyersCstTinNo"].ToString();
SellerVatTinNo = "00000000000V";
SellerCstTinNo = "11111111111V";
}
drSelect.Close();
con.Close();
#region Without border print format maganlal
var FontTextColor = FontFactory.GetFont("Arial", 10, iTextSharp.text.BaseColor.WHITE);
var MainTextRegular = FontFactory.GetFont("Arial", 8, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularSmall = FontFactory.GetFont("Arial", 7, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularExtraSmall = FontFactory.GetFont("Arial", 6, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularBold = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD);
var MainTextRegularSmallBold = FontFactory.GetFont("Arial", 7, iTextSharp.text.Font.BOLD);
var MainTextRegularHead = FontFactory.GetFont("Arial", 12, iTextSharp.text.BaseColor.BLACK);
var MainTextBold = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD);
var MainHeaderTextBold = FontFactory.GetFont("Arial", 15, iTextSharp.text.Font.BOLD);
var MainHeaderText = FontFactory.GetFont("Arial", 12, iTextSharp.text.BaseColor.BLACK);
string url = "http://localhost:63968/img/Maganlal_Fevicon_logo.jpg";
iTextSharp.text.Image jpg1 = iTextSharp.text.Image.GetInstance(new Uri(url));
jpg1.ScaleAbsolute(55f, 55f);
iTextSharp.text.Font Fonth1 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10f);
iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(PageSize.B5, 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
//created Master table
PdfPTable MasterMainTable = new PdfPTable(new float[] { 48f, 4f, 48f });
MasterMainTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
MasterMainTable.TotalWidth = 800f;
MasterMainTable.LockedWidth = true;
MasterMainTable.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell MasterMainTable_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(""));
MasterMainTable_Cell01.HorizontalAlignment = 0;
MasterMainTable_Cell01.BorderWidth = 0;
PdfPCell MasterMainTable_SpaceCell = new PdfPCell(new iTextSharp.text.Paragraph(" "));
MasterMainTable_SpaceCell.HorizontalAlignment = 0;
MasterMainTable_SpaceCell.BorderWidth = 0;
PdfPCell MasterMainTable_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(""));
MasterMainTable_Cell02.HorizontalAlignment = 0;
MasterMainTable_Cell02.BorderWidth = 0;
//print data from here
PdfPTable MainTable = new PdfPTable(1);
MainTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
MainTable.TotalWidth = 474f;
MainTable.LockedWidth = true;
MainTable.HorizontalAlignment = Element.ALIGN_LEFT;
MainTable.SpacingBefore = 85;
//1st row
PdfPCell MainTableCell1 = new PdfPCell(new iTextSharp.text.Paragraph(" "));
MainTableCell1.HorizontalAlignment = 0;
MainTableCell1.BorderWidth = 0;
//created nested table
PdfPTable nestedTable = new PdfPTable(new float[] { 8f, 32f, 15f, 15f, 15f, 15f });
nestedTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTable.TotalWidth = 474f;
nestedTable.LockedWidth = true;
PdfPCell nestedTable_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainHeaderTextBold));
nestedTable_Cell01.HorizontalAlignment = Element.ALIGN_TOP;
nestedTable_Cell01.VerticalAlignment = Element.ALIGN_TOP;
nestedTable_Cell01.BorderWidth = 0;
nestedTable_Cell01.Colspan = 1;
nestedTable_Cell01.Rowspan = 6;
nestedTable_Cell01.AddElement(jpg1);
PdfPCell nestedTableCell01 = new PdfPCell(new iTextSharp.text.Paragraph("MFP PRODUCTS", MainHeaderTextBold));
nestedTableCell01.HorizontalAlignment = 1;
nestedTableCell01.BorderWidth = 0;
nestedTableCell01.Colspan = 5;
PdfPCell nestedTableCell02 = new PdfPCell(new iTextSharp.text.Paragraph("MODI PLAZA, SHOP NO.101, OLD MUMBAI-PUNE HIGHWAY, ", MainTextRegular));
nestedTableCell02.HorizontalAlignment = 1;
nestedTableCell02.BorderWidth = 0;
nestedTableCell02.Colspan = 5;
PdfPCell nestedTableCell03 = new PdfPCell(new iTextSharp.text.Paragraph("BESIDES HARI INTERNATIONAL, LONAVALA 410401, DIST:PUNE INDIA", MainTextRegular));
nestedTableCell03.HorizontalAlignment = 1;
nestedTableCell03.BorderWidth = 0;
nestedTableCell03.Colspan = 5;
PdfPCell nestedTableCell04 = new PdfPCell(new iTextSharp.text.Paragraph("EMAIL:mfpproducts@gmail.com, (+91-9689-9689-01), (+91-9689-9689-02)\n\n", MainTextRegular));
nestedTableCell04.HorizontalAlignment = 1;
nestedTableCell04.BorderWidth = 0;
nestedTableCell04.Colspan = 5;
PdfPCell nestedTableCell05 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
nestedTableCell05.HorizontalAlignment = 1;
nestedTableCell05.BorderWidth = 0;
nestedTableCell05.Colspan = 5;
PdfPCell nestedTableCell06 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
nestedTableCell06.HorizontalAlignment = 1;
nestedTableCell06.BorderWidth = 0;
nestedTableCell06.Colspan = 5;
//nestedTable.AddCell(nestedTable_Cell01);
//nestedTable.AddCell(nestedTableCell01);
//nestedTable.AddCell(nestedTableCell02);
//nestedTable.AddCell(nestedTableCell03);
//nestedTable.AddCell(nestedTableCell04);
//nestedTable.AddCell(nestedTableCell05);
//nestedTable.AddCell(nestedTableCell06);
PdfPCell MainTableCell11 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegular));
MainTableCell11.HorizontalAlignment = 1;
MainTableCell11.BorderWidth = 0;
MainTableCell11.Colspan = 6;
PdfPTable nestedTableForCell11 = new PdfPTable(new float[] { 20f, 60f, 20f });
nestedTableForCell11.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell11.TotalWidth = 474f;
nestedTableForCell11.LockedWidth = true;
PdfPCell nestedTableForCell11_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Bill No :" + BillNumber + "", MainTextRegular));
nestedTableForCell11_Cell01.HorizontalAlignment = 0;
nestedTableForCell11_Cell01.BorderWidth = 0;
PdfPCell nestedTableForCell11_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph("TAX INVOICE", MainTextRegularBold));
nestedTableForCell11_Cell02.HorizontalAlignment = 1;
nestedTableForCell11_Cell02.BorderWidth = 0;
PdfPCell nestedTableForCell11_Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("Date :" + BillDate + "", MainTextRegular));
nestedTableForCell11_Cell03.HorizontalAlignment = 2;
nestedTableForCell11_Cell03.BorderWidth = 0;
nestedTableForCell11.AddCell(nestedTableForCell11_Cell01);
nestedTableForCell11.AddCell(nestedTableForCell11_Cell02);
nestedTableForCell11.AddCell(nestedTableForCell11_Cell03);
MainTableCell11.AddElement(nestedTableForCell11);
nestedTable.AddCell(MainTableCell11);
//party name and address
//first column
PdfPCell nestedTableCell12 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegular));
nestedTableCell12.HorizontalAlignment = 0;
nestedTableCell12.BorderWidth = 0;
nestedTableCell12.Colspan = 6;
PdfPTable nestedTableForCell12 = new PdfPTable(new float[] { 100f });
nestedTableForCell11.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell11.TotalWidth = 100f;
nestedTableForCell11.LockedWidth = true;
nestedTableForCell12.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell nestedTableForCell12_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Party Name : " + PartyName + " ", MainTextRegular));
nestedTableForCell12_Cell01.HorizontalAlignment = 0;
nestedTableForCell12_Cell01.BorderWidth = 0;
nestedTableForCell12.AddCell(nestedTableForCell12_Cell01);
nestedTableCell12.AddElement(nestedTableForCell12);
nestedTable.AddCell(nestedTableCell12);
//2nd column
//PdfPCell nestedTableCell13 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegular));
//nestedTableCell13.HorizontalAlignment = 1;
//nestedTableCell13.BorderWidth = 0;
//nestedTableCell13.Colspan = 3;
//PdfPTable nestedTableForCell13 = new PdfPTable(new float[] { 30f,70f });
//nestedTableForCell13.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
//nestedTableForCell13.TotalWidth = 150f;
//nestedTableForCell13.LockedWidth = true;
//PdfPCell nestedTableForCell13_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Date", MainTextRegular));
//nestedTableForCell13_Cell01.HorizontalAlignment = 0;
//nestedTableForCell13_Cell01.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(": {Date}", MainTextRegular));
//nestedTableForCell13_Cell02.HorizontalAlignment = 0;
//nestedTableForCell13_Cell02.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
//nestedTableForCell13_Cell03.HorizontalAlignment = 0;
//nestedTableForCell13_Cell03.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell04 = new PdfPCell(new iTextSharp.text.Paragraph(": {BillNo}", MainTextRegular));
//nestedTableForCell13_Cell04.HorizontalAlignment = 0;
//nestedTableForCell13_Cell04.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell05 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
//nestedTableForCell13_Cell05.HorizontalAlignment = 0;
//nestedTableForCell13_Cell05.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell06 = new PdfPCell(new iTextSharp.text.Paragraph(": {Invoice No}", MainTextRegular));
//nestedTableForCell13_Cell06.HorizontalAlignment = 0;
//nestedTableForCell13_Cell06.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell07 = new PdfPCell(new iTextSharp.text.Paragraph("Challan No", MainTextRegular));
//nestedTableForCell13_Cell07.HorizontalAlignment = 0;
//nestedTableForCell13_Cell07.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell08 = new PdfPCell(new iTextSharp.text.Paragraph(": {Challan No}", MainTextRegular));
//nestedTableForCell13_Cell08.HorizontalAlignment = 0;
//nestedTableForCell13_Cell08.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell09 = new PdfPCell(new iTextSharp.text.Paragraph("P.O. No", MainTextRegular));
//nestedTableForCell13_Cell09.HorizontalAlignment = 0;
//nestedTableForCell13_Cell09.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell010 = new PdfPCell(new iTextSharp.text.Paragraph(": {PO_No}", MainTextRegular));
//nestedTableForCell13_Cell010.HorizontalAlignment = 0;
//nestedTableForCell13_Cell010.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell011 = new PdfPCell(new iTextSharp.text.Paragraph("Date", MainTextRegular));
//nestedTableForCell13_Cell011.HorizontalAlignment = 0;
//nestedTableForCell13_Cell011.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell012 = new PdfPCell(new iTextSharp.text.Paragraph(": {PO_Date}", MainTextRegular));
//nestedTableForCell13_Cell012.HorizontalAlignment = 0;
//nestedTableForCell13_Cell012.BorderWidth = 0;
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell01);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell02);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell03);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell04);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell05);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell06);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell07);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell08);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell09);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell010);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell011);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell012);
//nestedTableCell13.AddElement(nestedTableForCell13);
//nestedTable.AddCell(nestedTableCell13);
//description
PdfPCell nestedTableCell14 = new PdfPCell(new iTextSharp.text.Paragraph("Sr.No", MainTextRegularBold));
nestedTableCell14.HorizontalAlignment = 1;
nestedTableCell14.BorderWidth = 0;
PdfPCell nestedTableCell15 = new PdfPCell(new iTextSharp.text.Paragraph("Product", MainTextRegularBold));
nestedTableCell15.HorizontalAlignment = 1;
nestedTableCell15.BorderWidth = 0;
PdfPCell nestedTableCell16 = new PdfPCell(new iTextSharp.text.Paragraph("Rate", MainTextRegularBold));
nestedTableCell16.HorizontalAlignment = 1;
nestedTableCell16.BorderWidth = 0;
PdfPCell nestedTableCell17 = new PdfPCell(new iTextSharp.text.Paragraph("Qantity", MainTextRegularBold));
nestedTableCell17.HorizontalAlignment = 2;
nestedTableCell17.BorderWidth = 0;
PdfPCell nestedTableCell18 = new PdfPCell(new iTextSharp.text.Paragraph("No OF Box ", MainTextRegularBold));
nestedTableCell18.HorizontalAlignment = 2;
nestedTableCell18.BorderWidth = 0;
PdfPCell nestedTableCell19 = new PdfPCell(new iTextSharp.text.Paragraph("Amount", MainTextRegularBold));
nestedTableCell19.HorizontalAlignment = 2;
nestedTableCell19.BorderWidth = 0;
nestedTable.AddCell(nestedTableCell14);
nestedTable.AddCell(nestedTableCell15);
nestedTable.AddCell(nestedTableCell16);
nestedTable.AddCell(nestedTableCell17);
nestedTable.AddCell(nestedTableCell18);
nestedTable.AddCell(nestedTableCell19);
SqlCommand cmdSelectItems = new SqlCommand("select s.ID as BillNumber,s.Date as BillDate,s.DiscountRate as DiscountRate,s.DiscountAmt as DiscountAmount,s.GrossAmt as TotalAmount,s.VatRate as VatRate,s.VatAmt as VatAmount,s.GrandTotal as GrandTotal,s.PaidAmt as PaidAmount,sd.Quantity,sd.Box,sd.PcsPerBox,sd.Price,sd.Amount,p.Name as ProductName,p.Price as ProductPrice,p.BoxQty,c.FirmName as PartyName,c.PersonName,c.VATTin as BuyersVatTinNo,c.CSTTin as BuyersCstTinNo,m.Name from SalesDetails sd inner join SalesForm s on s.ID=sd.SalesForm inner join MstProduct p on p.ID=sd.Product inner join MstCustomer c on c.ID=s.Customer inner join MstMainCategory m on m.ID=p.MainCategory where s.ID=" + txtBill.Text + "", con);//"+txtBill.Text+"
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmdSelectItems;
DataTable dtItems = new DataTable();
sda.Fill(dtItems);
SrNo = 1;
for (int i = 0; i < dtItems.Rows.Count; i++)
{
ProductName = dtItems.Rows[i][14].ToString();
ProductRate = dtItems.Rows[i][15].ToString();
ProductQuantity = dtItems.Rows[i][09].ToString();
ProductNumberOfBox = dtItems.Rows[i][11].ToString();
ProductAmount = dtItems.Rows[i][13].ToString();
//description Data
PdfPCell nestedTableCell20 = new PdfPCell(new iTextSharp.text.Paragraph("" + SrNo + "", MainTextRegularSmall));
nestedTableCell20.HorizontalAlignment = 1;
nestedTableCell20.BorderWidthTop = 0;
nestedTableCell20.BorderWidthLeft = 0;
nestedTableCell20.BorderWidthRight = 0;
nestedTableCell20.BorderWidthBottom = 0;
PdfPCell nestedTableCell21 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductName + "", MainTextRegularSmall));
nestedTableCell21.HorizontalAlignment = 1;
nestedTableCell21.BorderWidthTop = 0;
nestedTableCell21.BorderWidthLeft = 0;
nestedTableCell21.BorderWidthRight = 0;
nestedTableCell21.BorderWidthBottom = 0;
PdfPCell nestedTableCell22 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductRate + "", MainTextRegularSmall));
nestedTableCell22.HorizontalAlignment = 1;
nestedTableCell22.BorderWidthTop = 0;
nestedTableCell22.BorderWidthLeft = 0;
nestedTableCell22.BorderWidthRight = 0;
nestedTableCell22.BorderWidthBottom = 0;
PdfPCell nestedTableCell23 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductQuantity + "", MainTextRegularSmall));
nestedTableCell23.HorizontalAlignment = 2;
nestedTableCell23.BorderWidthTop = 0;
nestedTableCell23.BorderWidthLeft = 0;
nestedTableCell23.BorderWidthRight = 0;
nestedTableCell23.BorderWidthBottom = 0;
PdfPCell nestedTableCell24 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductNumberOfBox + "", MainTextRegularSmall));
nestedTableCell24.HorizontalAlignment = 2;
nestedTableCell24.BorderWidthTop = 0;
nestedTableCell24.BorderWidthLeft = 0;
nestedTableCell24.BorderWidthRight = 0;
nestedTableCell24.BorderWidthBottom = 0;
PdfPCell nestedTableCell25 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductAmount + "", MainTextRegularSmall));
nestedTableCell25.HorizontalAlignment = 2;
nestedTableCell25.BorderWidthTop = 0;
nestedTableCell25.BorderWidthLeft = 0;
nestedTableCell25.BorderWidthRight = 0;
nestedTableCell25.BorderWidthBottom = 0;
nestedTable.AddCell(nestedTableCell20);
nestedTable.AddCell(nestedTableCell21);
nestedTable.AddCell(nestedTableCell22);
nestedTable.AddCell(nestedTableCell23);
nestedTable.AddCell(nestedTableCell24);
nestedTable.AddCell(nestedTableCell25);
SrNo++;
}
PdfPCell nestedTableCell_20 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_20.HorizontalAlignment = 1;
nestedTableCell_20.BorderWidthTop = 0;
nestedTableCell_20.BorderWidthLeft = 0;
nestedTableCell_20.BorderWidthRight = 0;
nestedTableCell_20.BorderWidthBottom = 0;
PdfPCell nestedTableCell_21 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_21.HorizontalAlignment = 1;
nestedTableCell_21.BorderWidthTop = 0;
nestedTableCell_21.BorderWidthLeft = 0;
nestedTableCell_21.BorderWidthRight = 0;
nestedTableCell_21.BorderWidthBottom = 0;
PdfPCell nestedTableCell_22 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_22.HorizontalAlignment = 1;
nestedTableCell_22.BorderWidthTop = 0;
nestedTableCell_22.BorderWidthLeft = 0;
nestedTableCell_22.BorderWidthRight = 0;
nestedTableCell_22.BorderWidthBottom = 0;
PdfPCell nestedTableCell_23 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_23.HorizontalAlignment = 2;
nestedTableCell_23.BorderWidthTop = 0;
nestedTableCell_23.BorderWidthLeft = 0;
nestedTableCell_23.BorderWidthRight = 0;
nestedTableCell_23.BorderWidthBottom = 0;
PdfPCell nestedTableCell_24 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_24.HorizontalAlignment = 2;
nestedTableCell_24.BorderWidthTop = 0;
nestedTableCell_24.BorderWidthLeft = 0;
nestedTableCell_24.BorderWidthRight = 0;
nestedTableCell_24.BorderWidthBottom = 0;
PdfPCell nestedTableCell_25 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_25.HorizontalAlignment = 2;
nestedTableCell_25.BorderWidthTop = 0;
nestedTableCell_25.BorderWidthLeft = 0;
nestedTableCell_25.BorderWidthRight = 0;
nestedTableCell_25.BorderWidthBottom = 0;
nestedTable.AddCell(nestedTableCell_20);
nestedTable.AddCell(nestedTableCell_21);
nestedTable.AddCell(nestedTableCell_22);
nestedTable.AddCell(nestedTableCell_23);
nestedTable.AddCell(nestedTableCell_24);
nestedTable.AddCell(nestedTableCell_25);
//calculation i.e discount, vat ***********************
PdfPCell nestedTableCell20_1 = new PdfPCell(new iTextSharp.text.Paragraph("\nTOTAL\n\n", MainTextRegularBold));
nestedTableCell20_1.HorizontalAlignment = 1;
nestedTableCell20_1.Colspan = 3;
nestedTableCell20_1.BorderWidthTop = 0;
nestedTableCell20_1.BorderWidthLeft = 0;
nestedTableCell20_1.BorderWidthRight = 0;
nestedTableCell20_1.BorderWidthBottom = 0;
PdfPCell nestedTableCell23_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + TotalQuantity + "\n\n", MainTextRegularSmall));
nestedTableCell23_1.HorizontalAlignment = 2;
nestedTableCell23_1.BorderWidthBottom = 0;
nestedTableCell23_1.BorderWidthTop = 0;
nestedTableCell23_1.BorderWidthLeft = 0;
nestedTableCell23_1.BorderWidthRight = 0;
PdfPCell nestedTableCell24_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + TotalBoxes + "\n\n", MainTextRegularSmall));
nestedTableCell24_1.HorizontalAlignment = 2;
nestedTableCell24_1.BorderWidth = 0;
nestedTableCell24_1.BorderWidthTop = 0;
nestedTableCell24_1.BorderWidthLeft = 0;
nestedTableCell24_1.BorderWidthRight = 0;
nestedTableCell24_1.BorderWidthBottom = 0;
PdfPCell nestedTableCell25_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + ItemTotalAmount + "\n\n", MainTextRegularSmall));
nestedTableCell25_1.HorizontalAlignment = 2;
nestedTableCell25_1.BorderWidth = 0;
nestedTableCell25_1.BorderWidthTop = 0;
nestedTableCell25_1.BorderWidthLeft = 0;
nestedTableCell25_1.BorderWidthBottom = 0;
nestedTable.AddCell(nestedTableCell20_1);
nestedTable.AddCell(nestedTableCell23_1);
nestedTable.AddCell(nestedTableCell24_1);
nestedTable.AddCell(nestedTableCell25_1);
string rupee = "One Thousand Only";
PdfPCell nestedTableCell26 = new PdfPCell(new iTextSharp.text.Paragraph("Total Amount in words:" + AmountInWords + "", MainTextRegularSmall));
nestedTableCell26.HorizontalAlignment = Element.ALIGN_LEFT;
nestedTableCell26.Colspan = 4;
//nestedTableCell26.Rowspan = 4;
nestedTableCell26.BorderWidthTop = 0;
nestedTableCell26.BorderWidthLeft = 0;
nestedTableCell26.BorderWidthRight = 0;
nestedTableCell26.BorderWidthBottom = 0;
PdfPCell nestedTableCell28 = new PdfPCell(new iTextSharp.text.Paragraph("\n(-)Discount " + DiscountRate + "%\n\n", MainTextRegularSmall));
nestedTableCell28.HorizontalAlignment = 2;
nestedTableCell28.BorderWidthLeft = 0;
nestedTableCell28.BorderWidthRight = 0;
nestedTableCell28.BorderWidthBottom = 0;
nestedTableCell28.BorderWidthTop = 0;
PdfPCell nestedTableCell29 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + DiscountAmount + "\n\n", MainTextRegularSmall));
nestedTableCell29.HorizontalAlignment = 2;
nestedTableCell29.BorderWidth = 0;
nestedTableCell29.BorderWidthRight = 0;
nestedTableCell29.BorderWidthBottom = 0;
nestedTableCell29.BorderWidthLeft = 0;
nestedTable.AddCell(nestedTableCell26);
nestedTable.AddCell(nestedTableCell28);
nestedTable.AddCell(nestedTableCell29);
PdfPCell nestedTable_Cell30 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularSmall));
nestedTable_Cell30.HorizontalAlignment = 2;
nestedTable_Cell30.BorderWidthTop = 0;
nestedTable_Cell30.BorderWidthRight = 0;
nestedTable_Cell30.BorderWidthBottom = 0;
nestedTable_Cell30.BorderWidthLeft = 0;
nestedTable_Cell30.Colspan = 4;
nestedTable_Cell30.Rowspan = 2;
PdfPTable nestedTableFornestedTable_Cell30 = new PdfPTable(new float[] { 50f, 50f });
nestedTableFornestedTable_Cell30.TotalWidth = 329f;
nestedTableFornestedTable_Cell30.LockedWidth = true;
nestedTableFornestedTable_Cell30.HorizontalAlignment = Element.ALIGN_LEFT;
nestedTableFornestedTable_Cell30.SpacingBefore = 2f;
nestedTableFornestedTable_Cell30.SpacingAfter = 4f;
Phrase pBVatTin = new Phrase();
Chunk c1 = new Chunk("Buyer's VAT Tin", MainTextRegularSmallBold);
Chunk c2 = new Chunk(": " + BuyersVatTinNo + "\n", MainTextRegularSmall);
pBVatTin.Add(c1);
pBVatTin.Add(c2);
PdfPCell nestedTableFornestedTable_Cell30_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(""));
nestedTableFornestedTable_Cell30_Cell01.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthTop = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell01.AddElement(pBVatTin);
Phrase pBCstTin = new Phrase();
Chunk c3 = new Chunk("Buyer's CST Tin", MainTextRegularSmallBold);
Chunk c4 = new Chunk(": " + BuyersCstTinNo + "", MainTextRegularSmall);
pBCstTin.Add(c3);
pBCstTin.Add(c4);
PdfPCell nestedTableFornestedTable_Cell30_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell02.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidth = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell02.AddElement(pBCstTin);
Phrase pSVatTin = new Phrase();
Chunk c5 = new Chunk("Seller's CST Tin", MainTextRegularSmallBold);
Chunk c6 = new Chunk(": " + SellerVatTinNo + "", MainTextRegularSmall);
pSVatTin.Add(c5);
pSVatTin.Add(c6);
PdfPCell nestedTableFornestedTable_Cell30_Cell03 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell03.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthTop = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell03.AddElement(pSVatTin);
Phrase pSCstTin = new Phrase();
Chunk c7 = new Chunk("Seller's CST Tin", MainTextRegularSmallBold);
Chunk c8 = new Chunk(": " + SellerCstTinNo + "", MainTextRegularSmall);
pSCstTin.Add(c7);
pSCstTin.Add(c8);
PdfPCell nestedTableFornestedTable_Cell30_Cell04 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell04.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthTop = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell04.AddElement(pSCstTin);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell01);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell02);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell03);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell04);
nestedTable_Cell30.AddElement(nestedTableFornestedTable_Cell30);
PdfPCell nestedTableCell30 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell30.HorizontalAlignment = 2;
nestedTableCell30.BorderWidthTop = 0;
nestedTableCell30.BorderWidthRight = 0;
nestedTableCell30.BorderWidthBottom = 0;
nestedTableCell30.BorderWidthLeft = 0;
PdfPCell nestedTableCell31 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + WithDicoount_TotalAmount + "\n\n", MainTextRegularSmall));
nestedTableCell31.HorizontalAlignment = 2;
nestedTableCell31.BorderWidthTop = 0;
nestedTableCell31.BorderWidthRight = 0;
nestedTableCell31.BorderWidthBottom = 0;
nestedTableCell31.BorderWidthLeft = 0;
nestedTable.AddCell(nestedTable_Cell30);
nestedTable.AddCell(nestedTableCell30);
nestedTable.AddCell(nestedTableCell31);
PdfPCell nestedTable_Cell32 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));// I/We hereby certify that my/our registration certificate under the Maharashtra Value Addess Tax Act.2002 is in force on the date on which the sale of goods specified in this 'Tax Invoice' is made by me/us and that the transaction of sale covered by this 'Tax Invoice' has been effected by me/us and it shall be accounted for in the turn over of sales while fililng return and due tax, if any payable on the sales has been paid shall be paid.\n\n\n\n\n*T&c apply
nestedTable_Cell32.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
nestedTable_Cell32.VerticalAlignment = Element.ALIGN_TOP;
nestedTable_Cell32.BorderWidthTop = 0;
nestedTable_Cell32.BorderWidthRight = 0;
nestedTable_Cell32.BorderWidthBottom = 0;
nestedTable_Cell32.BorderWidthLeft = 0;
nestedTable_Cell32.Colspan = 4;
nestedTable_Cell32.Rowspan = 5;
PdfPCell nestedTableCell32 = new PdfPCell(new iTextSharp.text.Paragraph("\n(+)Vat " + VatRate + "%\n\n", MainTextRegularSmall));
nestedTableCell32.HorizontalAlignment = 2;
nestedTableCell32.BorderWidthTop = 0;
nestedTableCell32.BorderWidthRight = 0;
nestedTableCell32.BorderWidthBottom = 0;
nestedTableCell32.BorderWidthLeft = 0;
PdfPCell nestedTableCell33 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + VatAmount + "\n\n", MainTextRegularSmall));
nestedTableCell33.HorizontalAlignment = 2;
nestedTableCell33.BorderWidthTop = 0;
nestedTableCell33.BorderWidthRight = 0;
nestedTableCell33.BorderWidthBottom = 0;
nestedTableCell33.BorderWidthLeft = 0;
//nestedTable.AddCell(nestedTable_Cell32);
nestedTable.AddCell(nestedTableCell32);
nestedTable.AddCell(nestedTableCell33);
//PdfPCell nestedTable_Cell34 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
//nestedTable_Cell34.HorizontalAlignment = 2;
//nestedTable_Cell34.BorderWidthTop = 0;
//nestedTable_Cell34.BorderWidthRight = 0;
//nestedTable_Cell34.BorderWidthBottom = 0;
//nestedTable_Cell34.BorderWidthLeft= 0;
//nestedTable_Cell34.Colspan = 4;
PdfPCell nestedTableCell34 = new PdfPCell(new iTextSharp.text.Paragraph("\n\nGrand Total", MainTextRegularSmall));
nestedTableCell34.HorizontalAlignment = 2;
nestedTableCell34.BorderWidthTop = 0;
nestedTableCell34.BorderWidthRight = 0;
nestedTableCell34.BorderWidthBottom = 0;
nestedTableCell34.BorderWidthLeft = 0;
PdfPCell nestedTableCell35 = new PdfPCell(new iTextSharp.text.Paragraph("{Rounded Value}\n\n" + WithVat_GrandTotal + "\n\n", MainTextRegularSmall));
nestedTableCell35.HorizontalAlignment = 2;
nestedTableCell35.BorderWidthTop = 0;
nestedTableCell35.BorderWidthRight = 0;
nestedTableCell35.BorderWidthBottom = 0;
nestedTableCell35.BorderWidthLeft = 0;
nestedTable.AddCell(nestedTable_Cell32);
nestedTable.AddCell(nestedTableCell34);
nestedTable.AddCell(nestedTableCell35);
//created row for vattin no
//PdfPCell nestedTableCell36 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
//nestedTableCell36.HorizontalAlignment = 2;
//nestedTableCell36.BorderWidth = 0;
//nestedTableCell36.Colspan = 3;
//PdfPTable nestedTableForCell36 = new PdfPTable(new float[] { 44f,56f });
//nestedTableForCell36.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
//nestedTableForCell36.TotalWidth = 170f;
//nestedTableForCell36.LockedWidth = true;
//nestedTableForCell36.HorizontalAlignment = Element.ALIGN_LEFT;
//nestedTableForCell36.SpacingBefore = 0f;
//PdfPCell nestedTableForCell36Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Buyer's VATtin No", MainTextRegularBold));
//nestedTableForCell36Cell01.HorizontalAlignment = 0;
//nestedTableForCell36Cell01.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(": ", MainTextRegularSmall));
//nestedTableForCell36Cell02.HorizontalAlignment = 1;
//nestedTableForCell36Cell02.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("Seller's VATtin No", MainTextRegularBold));
//nestedTableForCell36Cell03.HorizontalAlignment = 0;
//nestedTableForCell36Cell03.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell04 = new PdfPCell(new iTextSharp.text.Paragraph(": ", MainTextRegularSmall));
//nestedTableForCell36Cell04.HorizontalAlignment = 1;
//nestedTableForCell36Cell04.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell05 = new PdfPCell(new iTextSharp.text.Paragraph("CST TIN No", MainTextRegularBold));
//nestedTableForCell36Cell05.HorizontalAlignment = 0;
//nestedTableForCell36Cell05.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell06 = new PdfPCell(new iTextSharp.text.Paragraph(": ", MainTextRegularSmall));
//nestedTableForCell36Cell06.HorizontalAlignment = 1;
//nestedTableForCell36Cell06.BorderWidth = 0;
//nestedTableForCell36.AddCell(nestedTableForCell36Cell01);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell02);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell03);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell04);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell05);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell06);
//nestedTableCell36.AddElement(nestedTableForCell36);
//nestedTable.AddCell(nestedTableCell36);
PdfPCell nestedTableCell37 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularBold));
nestedTableCell37.HorizontalAlignment = 0;
nestedTableCell37.BorderWidth = 0;
nestedTableCell37.Colspan = 3;
//nestedTable.AddCell(nestedTableCell37);
//Terms and conditions
//created row for vattin no
PdfPCell nestedTableCell38 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell38.HorizontalAlignment = 2;
nestedTableCell38.BorderWidth = 0;
nestedTableCell38.Colspan = 4;
PdfPTable nestedTableForCell38 = new PdfPTable(new float[] { 100f });
nestedTableForCell38.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell38.TotalWidth = 400f;
nestedTableForCell38.LockedWidth = true;
nestedTableForCell38.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell nestedTableForCell38Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularBold));
nestedTableForCell38Cell01.HorizontalAlignment = 0;
nestedTableForCell38Cell01.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularExtraSmall));//terms 1. RATES ARE QUOTED EX-FACTORY BASIS.
nestedTableForCell38Cell02.HorizontalAlignment = 0;
nestedTableForCell38Cell02.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("2. VAT TAX 5%, TRANSPORT AND OCTROI WILL BE CHARGED EXTRA IF APPLICABLE.", MainTextRegularExtraSmall));
nestedTableForCell38Cell03.HorizontalAlignment = 0;
nestedTableForCell38Cell03.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell04 = new PdfPCell(new iTextSharp.text.Paragraph("3. GOODS WILL BE DISPATCHED WITHIN 8 DAYS AFTER RECEIVING COMPLETE PAYMENT WITH PO.", MainTextRegularExtraSmall));
nestedTableForCell38Cell04.HorizontalAlignment = 0;
nestedTableForCell38Cell04.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell05 = new PdfPCell(new iTextSharp.text.Paragraph("4. REPLACEMENT AND UNSOLD MATERIAL WILL NOT BE TAKEN BACK OR INTERTAINED.", MainTextRegularExtraSmall));
nestedTableForCell38Cell05.HorizontalAlignment = 0;
nestedTableForCell38Cell05.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell06 = new PdfPCell(new iTextSharp.text.Paragraph("5. CHANGES IN PRICE LIST RESERVED WITH THE COMPANY.", MainTextRegularExtraSmall));
nestedTableForCell38Cell06.HorizontalAlignment = 0;
nestedTableForCell38Cell06.BorderWidth = 0;
nestedTableForCell38.AddCell(nestedTableForCell38Cell01);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell02);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell03);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell04);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell05);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell06);
//nestedTableCell38.AddElement(nestedTableForCell38);
nestedTable.AddCell(nestedTableCell38);
PdfPCell nestedTableCell39 = new PdfPCell(new iTextSharp.text.Paragraph("FOR Number1 CHIKKI", MainTextRegularSmallBold));
nestedTableCell39.HorizontalAlignment = 2;
nestedTableCell39.BorderWidth = 0;
nestedTableCell39.Colspan = 2;
nestedTable.AddCell(nestedTableCell39);
PdfPCell nestedTableCell40 = new PdfPCell(new iTextSharp.text.Paragraph("\n\n\n(Propritor/Auth. Signature)", MainTextRegularSmallBold));
nestedTableCell40.HorizontalAlignment = 2;
nestedTableCell40.BorderWidth = 0;
nestedTableCell40.Colspan = 2;
nestedTable.AddCell(nestedTableCell40);
MainTableCell1.AddElement(nestedTable);
MainTable.AddCell(MainTableCell1);
//print main data is over
MasterMainTable_Cell01.AddElement(MainTable);
//MasterMainTable_Cell02.AddElement(MainTable);
MasterMainTable.AddCell(MasterMainTable_Cell01);
MasterMainTable.AddCell(MasterMainTable_SpaceCell);
MasterMainTable.AddCell(MasterMainTable_Cell02);
pdfDoc.Add(MasterMainTable);
pdfDoc.Close();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Write(pdfDoc);
// Response.Redirect("pdfDisplay.aspx");
HttpContext.Current.Response.End();
//string url1 = string.Format("pdfDisplay.aspx?FN={0}.pdf");
//string script = "<script type='text/javascript'>window.open(pdfDisplay.aspx)</script>";
//this.ClientScript.RegisterStartupScript(this.GetType(), "script", script);
//string filePath = Server.MapPath("~/Reports/") + Request.QueryString["FN"];
//this.Response.ContentType = "application/pdf";
//this.Response.AppendHeader("Content-Disposition;", "attachment;filename=" + Request.QueryString["FN"]);
////this.Response.WriteFile(filePath);
//this.Response.Write(filePath);
//this.Response.End();
//context.Response.Buffer = true;
//context.Response.Charset = "";
//if (context.Request.QueryString["download"] == "1")
//{
// context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
//}
//context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
//context.Response.ContentType = "application/pdf";
//context.Response.BinaryWrite(bytes);
//context.Response.Flush();
//context.Response.End();
//pdfDoc.Close();
//Response.ContentType = "application/pdf";
//Response.AddHeader("content-disposition", "attachment;filename=c:\abc.pdf");
//Response.Cache.SetCacheability(HttpCacheability.NoCache);
//Response.Write(pdfDoc);
//Response.End();
//string filePath = Server.MapPath("~/Reports/") + Request.QueryString["FN"];
//this.Response.ContentType = "application/pdf";
//this.Response.AppendHeader("Content-Disposition;", "attachment;filename=" + Request.QueryString["FN"]);
//this.Response.WriteFile(filePath);
//this.Response.End();
#endregion
}
protected void View(object sender, EventArgs e)
{
string url = string.Format("WebForm5.aspx?FN={0}.pdf", (sender as LinkButton).CommandArgument);
string script = "<script type='text/javascript'>window.open('" + url + "')</script>";
this.ClientScript.RegisterStartupScript(this.GetType(), "script", script);
}
public void PrintBill()
{
con.Close();
con.Open();
//select s.ID as BillNumber,s.Date as BillDate,s.DiscountRate as DiscountRate,s.DiscountAmt as DiscountAmount,s.GrossAmt as TotalAmount,s.VatRate as VatRate,s.VatAmt as VatAmount,s.GrandTotal as GrandTotal,s.PaidAmt as PaidAmount,sd.Quantity,sd.Box,sd.PcsPerBox,sd.Price,sd.Amount,p.Name as ProductName,p.Price as ProductPrice,p.BoxQty,c.FirmName as PartyName,c.PersonName,c.VATTin as BuyersVatTinNo,c.CSTTin as BuyersCstTinNo,m.Name from SalesDetails sd inner join SalesForm s on s.ID=sd.SalesForm inner join MstProduct p on p.ID=sd.Product inner join MstCustomer c on c.ID=s.Customer inner join MstMainCategory m on m.ID=p.MainCategory where s.ID=19
SqlCommand cmdSelect = new SqlCommand("select distinct s.ID as BillNumber,s.Date as BillDate,((select sum(sd.Amount) from SalesDetails sd where sd.SalesForm=" + txtBill.Text + ")) as ItemTotalAmount ,s.DiscountRate as DiscountRate,s.DiscountAmt as DiscountAmount,s.GrossAmt as WithDicoount_TotalAmount,s.VatRate as VatRate,s.VatAmt as VatAmount,s.GrandTotal as WithVat_GrandTotal,s.PaidAmt as PaidAmount,((select sum(sd.Quantity) from SalesDetails sd where sd.SalesForm=" + txtBill.Text + ")) as TotalQuantity ,((select sum(sd.Box) from SalesDetails sd where sd.SalesForm=" + txtBill.Text + ")) as TotalBox ,c.FirmName as PartyName,c.VATTin as BuyersVatTinNo,c.CSTTin as BuyersCstTinNo from SalesDetails sd inner join SalesForm s on s.ID=sd.SalesForm inner join MstProduct p on p.ID=sd.Product inner join MstCustomer c on c.ID=s.Customer where s.ID=" + txtBill.Text + "", con);
SqlDataReader drSelect = cmdSelect.ExecuteReader();
if (drSelect.Read())
{
BillNumber = drSelect["BillNumber"].ToString();
BillDate = drSelect["BillDate"].ToString();
PartyName = drSelect["PartyName"].ToString();
//TotalQuantity = drSelect["TotalQuantity"].ToString();
ItemTotalAmount = drSelect["ItemTotalAmount"].ToString();
//AmountInWords = "Wait".ToString();
DiscountRate = drSelect["DiscountRate"].ToString();
DiscountAmount = drSelect["DiscountAmount"].ToString();
WithDicoount_TotalAmount = drSelect["WithDicoount_TotalAmount"].ToString();
VatRate = drSelect["VatRate"].ToString();
VatAmount = drSelect["VatAmount"].ToString();
WithVat_GrandTotal = drSelect["WithVat_GrandTotal"].ToString();
string word = ConvertNumbertoWords(Convert.ToInt32(WithVat_GrandTotal));
AmountInWords = word;
TotalQuantity = drSelect["TotalQuantity"].ToString();
TotalBoxes = drSelect["TotalBox"].ToString();
BuyersVatTinNo = drSelect["BuyersVatTinNo"].ToString();
BuyersCstTinNo = drSelect["BuyersCstTinNo"].ToString();
SellerVatTinNo = "27461430348V";
SellerCstTinNo = "27461430348V";
}
drSelect.Close();
con.Close();
#region Print Bill Code
var FontTextColor = FontFactory.GetFont("Arial", 10, iTextSharp.text.BaseColor.WHITE);
var MainTextRegular = FontFactory.GetFont("Arial", 8, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularSmall = FontFactory.GetFont("Arial", 7, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularExtraSmall = FontFactory.GetFont("Arial", 6, iTextSharp.text.BaseColor.BLACK);
var MainTextRegularBold = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD);
var MainTextRegularSmallBold = FontFactory.GetFont("Arial", 7, iTextSharp.text.Font.BOLD);
var MainTextRegularHead = FontFactory.GetFont("Arial", 12, iTextSharp.text.BaseColor.BLACK);
var MainTextBold = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.BOLD);
var MainHeaderTextBold = FontFactory.GetFont("Arial", 15, iTextSharp.text.Font.BOLD);
var MainHeaderText = FontFactory.GetFont("Arial", 12, iTextSharp.text.BaseColor.BLACK);
string url = "http://localhost:63968/img/Maganlal_Fevicon_logo.jpg";
iTextSharp.text.Image jpg1 = iTextSharp.text.Image.GetInstance(new Uri(url));
jpg1.ScaleAbsolute(55f, 55f);
iTextSharp.text.Font Fonth1 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10f);
iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(PageSize.A4.Rotate(), 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream);
pdfDoc.Open();
//created Master table
PdfPTable MasterMainTable = new PdfPTable(new float[] { 48f, 4f, 48f });
MasterMainTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
MasterMainTable.TotalWidth = 800f;
MasterMainTable.LockedWidth = true;
MasterMainTable.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell MasterMainTable_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(""));
MasterMainTable_Cell01.HorizontalAlignment = 0;
MasterMainTable_Cell01.BorderWidth = 0;
PdfPCell MasterMainTable_SpaceCell = new PdfPCell(new iTextSharp.text.Paragraph(" "));
MasterMainTable_SpaceCell.HorizontalAlignment = 0;
MasterMainTable_SpaceCell.BorderWidth = 0;
PdfPCell MasterMainTable_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(""));
MasterMainTable_Cell02.HorizontalAlignment = 0;
MasterMainTable_Cell02.BorderWidth = 0;
//print data from here
PdfPTable MainTable = new PdfPTable(1);
MainTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
MainTable.TotalWidth = 400f;
MainTable.LockedWidth = true;
MainTable.HorizontalAlignment = Element.ALIGN_LEFT;
//1st row
PdfPCell MainTableCell1 = new PdfPCell(new iTextSharp.text.Paragraph(""));
MainTableCell1.HorizontalAlignment = 0;
MainTableCell1.BorderWidth = 1;
//created nested table
PdfPTable nestedTable = new PdfPTable(new float[] { 8f, 32f, 15f, 15f, 15f, 15f });
nestedTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTable.TotalWidth = 400f;
nestedTable.LockedWidth = true;
PdfPCell nestedTable_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainHeaderTextBold));
nestedTable_Cell01.HorizontalAlignment = Element.ALIGN_TOP;
nestedTable_Cell01.VerticalAlignment = Element.ALIGN_TOP;
nestedTable_Cell01.BorderWidth = 0;
nestedTable_Cell01.Colspan = 1;
nestedTable_Cell01.Rowspan = 6;
nestedTable_Cell01.AddElement(jpg1);
PdfPCell nestedTableCell01 = new PdfPCell(new iTextSharp.text.Paragraph("MFP PRODUCTS", MainHeaderTextBold));
nestedTableCell01.HorizontalAlignment = 1;
nestedTableCell01.BorderWidth = 0;
nestedTableCell01.Colspan = 5;
PdfPCell nestedTableCell02 = new PdfPCell(new iTextSharp.text.Paragraph("MODI PLAZA, SHOP NO.101, OLD MUMBAI-PUNE HIGHWAY, ", MainTextRegular));
nestedTableCell02.HorizontalAlignment = 1;
nestedTableCell02.BorderWidth = 0;
nestedTableCell02.Colspan = 5;
PdfPCell nestedTableCell03 = new PdfPCell(new iTextSharp.text.Paragraph("BESIDES HARI INTERNATIONAL, LONAVALA 410401, DIST:PUNE INDIA", MainTextRegular));
nestedTableCell03.HorizontalAlignment = 1;
nestedTableCell03.BorderWidth = 0;
nestedTableCell03.Colspan = 5;
PdfPCell nestedTableCell04 = new PdfPCell(new iTextSharp.text.Paragraph("EMAIL:mfpproducts@gmail.com, (+91-9689-9689-01), (+91-9689-9689-02)\n\n", MainTextRegular));
nestedTableCell04.HorizontalAlignment = 1;
nestedTableCell04.BorderWidth = 0;
nestedTableCell04.Colspan = 5;
PdfPCell nestedTableCell05 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
nestedTableCell05.HorizontalAlignment = 1;
nestedTableCell05.BorderWidth = 0;
nestedTableCell05.Colspan = 5;
PdfPCell nestedTableCell06 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
nestedTableCell06.HorizontalAlignment = 1;
nestedTableCell06.BorderWidth = 0;
nestedTableCell06.Colspan = 5;
nestedTable.AddCell(nestedTable_Cell01);
nestedTable.AddCell(nestedTableCell01);
nestedTable.AddCell(nestedTableCell02);
nestedTable.AddCell(nestedTableCell03);
nestedTable.AddCell(nestedTableCell04);
nestedTable.AddCell(nestedTableCell05);
nestedTable.AddCell(nestedTableCell06);
PdfPCell MainTableCell11 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegular));
MainTableCell11.HorizontalAlignment = 1;
MainTableCell11.BorderWidth = 1;
MainTableCell11.Colspan = 6;
PdfPTable nestedTableForCell11 = new PdfPTable(new float[] { 20f, 60f, 20f });
nestedTableForCell11.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell11.TotalWidth = 400f;
nestedTableForCell11.LockedWidth = true;
PdfPCell nestedTableForCell11_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Bill No :" + BillNumber + "", MainTextRegular));
nestedTableForCell11_Cell01.HorizontalAlignment = 0;
nestedTableForCell11_Cell01.BorderWidth = 0;
PdfPCell nestedTableForCell11_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph("TAX INVOICE", MainTextRegularBold));
nestedTableForCell11_Cell02.HorizontalAlignment = 1;
nestedTableForCell11_Cell02.BorderWidth = 0;
PdfPCell nestedTableForCell11_Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("Date :" + BillDate + "", MainTextRegular));
nestedTableForCell11_Cell03.HorizontalAlignment = 2;
nestedTableForCell11_Cell03.BorderWidth = 0;
nestedTableForCell11.AddCell(nestedTableForCell11_Cell01);
nestedTableForCell11.AddCell(nestedTableForCell11_Cell02);
nestedTableForCell11.AddCell(nestedTableForCell11_Cell03);
MainTableCell11.AddElement(nestedTableForCell11);
nestedTable.AddCell(MainTableCell11);
//party name and address
//first column
PdfPCell nestedTableCell12 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegular));
nestedTableCell12.HorizontalAlignment = 0;
nestedTableCell12.BorderWidth = 1;
nestedTableCell12.Colspan = 6;
PdfPTable nestedTableForCell12 = new PdfPTable(new float[] { 100f });
nestedTableForCell11.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell11.TotalWidth = 100f;
nestedTableForCell11.LockedWidth = true;
nestedTableForCell12.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell nestedTableForCell12_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Party Name :" + PartyName + " ", MainTextRegular));
nestedTableForCell12_Cell01.HorizontalAlignment = 0;
nestedTableForCell12_Cell01.BorderWidth = 0;
nestedTableForCell12.AddCell(nestedTableForCell12_Cell01);
nestedTableCell12.AddElement(nestedTableForCell12);
nestedTable.AddCell(nestedTableCell12);
//2nd column
//PdfPCell nestedTableCell13 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegular));
//nestedTableCell13.HorizontalAlignment = 1;
//nestedTableCell13.BorderWidth = 1;
//nestedTableCell13.Colspan = 3;
//PdfPTable nestedTableForCell13 = new PdfPTable(new float[] { 30f,70f });
//nestedTableForCell13.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
//nestedTableForCell13.TotalWidth = 150f;
//nestedTableForCell13.LockedWidth = true;
//PdfPCell nestedTableForCell13_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Date", MainTextRegular));
//nestedTableForCell13_Cell01.HorizontalAlignment = 0;
//nestedTableForCell13_Cell01.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(": {Date}", MainTextRegular));
//nestedTableForCell13_Cell02.HorizontalAlignment = 0;
//nestedTableForCell13_Cell02.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
//nestedTableForCell13_Cell03.HorizontalAlignment = 0;
//nestedTableForCell13_Cell03.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell04 = new PdfPCell(new iTextSharp.text.Paragraph(": {BillNo}", MainTextRegular));
//nestedTableForCell13_Cell04.HorizontalAlignment = 0;
//nestedTableForCell13_Cell04.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell05 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegular));
//nestedTableForCell13_Cell05.HorizontalAlignment = 0;
//nestedTableForCell13_Cell05.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell06 = new PdfPCell(new iTextSharp.text.Paragraph(": {Invoice No}", MainTextRegular));
//nestedTableForCell13_Cell06.HorizontalAlignment = 0;
//nestedTableForCell13_Cell06.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell07 = new PdfPCell(new iTextSharp.text.Paragraph("Challan No", MainTextRegular));
//nestedTableForCell13_Cell07.HorizontalAlignment = 0;
//nestedTableForCell13_Cell07.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell08 = new PdfPCell(new iTextSharp.text.Paragraph(": {Challan No}", MainTextRegular));
//nestedTableForCell13_Cell08.HorizontalAlignment = 0;
//nestedTableForCell13_Cell08.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell09 = new PdfPCell(new iTextSharp.text.Paragraph("P.O. No", MainTextRegular));
//nestedTableForCell13_Cell09.HorizontalAlignment = 0;
//nestedTableForCell13_Cell09.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell010 = new PdfPCell(new iTextSharp.text.Paragraph(": {PO_No}", MainTextRegular));
//nestedTableForCell13_Cell010.HorizontalAlignment = 0;
//nestedTableForCell13_Cell010.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell011 = new PdfPCell(new iTextSharp.text.Paragraph("Date", MainTextRegular));
//nestedTableForCell13_Cell011.HorizontalAlignment = 0;
//nestedTableForCell13_Cell011.BorderWidth = 0;
//PdfPCell nestedTableForCell13_Cell012 = new PdfPCell(new iTextSharp.text.Paragraph(": {PO_Date}", MainTextRegular));
//nestedTableForCell13_Cell012.HorizontalAlignment = 0;
//nestedTableForCell13_Cell012.BorderWidth = 0;
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell01);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell02);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell03);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell04);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell05);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell06);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell07);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell08);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell09);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell010);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell011);
//nestedTableForCell13.AddCell(nestedTableForCell13_Cell012);
//nestedTableCell13.AddElement(nestedTableForCell13);
//nestedTable.AddCell(nestedTableCell13);
//description
PdfPCell nestedTableCell14 = new PdfPCell(new iTextSharp.text.Paragraph("Sr.No", MainTextRegularBold));
nestedTableCell14.HorizontalAlignment = 1;
nestedTableCell14.BorderWidth = 1;
PdfPCell nestedTableCell15 = new PdfPCell(new iTextSharp.text.Paragraph("Product", MainTextRegularBold));
nestedTableCell15.HorizontalAlignment = 1;
nestedTableCell15.BorderWidth = 1;
PdfPCell nestedTableCell16 = new PdfPCell(new iTextSharp.text.Paragraph("Rate", MainTextRegularBold));
nestedTableCell16.HorizontalAlignment = 1;
nestedTableCell16.BorderWidth = 1;
PdfPCell nestedTableCell17 = new PdfPCell(new iTextSharp.text.Paragraph("Qantity", MainTextRegularBold));
nestedTableCell17.HorizontalAlignment = 2;
nestedTableCell17.BorderWidth = 1;
PdfPCell nestedTableCell18 = new PdfPCell(new iTextSharp.text.Paragraph("No OF Box ", MainTextRegularBold));
nestedTableCell18.HorizontalAlignment = 2;
nestedTableCell18.BorderWidth = 1;
PdfPCell nestedTableCell19 = new PdfPCell(new iTextSharp.text.Paragraph("Amount", MainTextRegularBold));
nestedTableCell19.HorizontalAlignment = 2;
nestedTableCell19.BorderWidth = 1;
nestedTable.AddCell(nestedTableCell14);
nestedTable.AddCell(nestedTableCell15);
nestedTable.AddCell(nestedTableCell16);
nestedTable.AddCell(nestedTableCell17);
nestedTable.AddCell(nestedTableCell18);
nestedTable.AddCell(nestedTableCell19);
SqlCommand cmdSelectItems = new SqlCommand("select s.ID as BillNumber,s.Date as BillDate,s.DiscountRate as DiscountRate,s.DiscountAmt as DiscountAmount,s.GrossAmt as TotalAmount,s.VatRate as VatRate,s.VatAmt as VatAmount,s.GrandTotal as GrandTotal,s.PaidAmt as PaidAmount,sd.Quantity,sd.Box,sd.PcsPerBox,sd.Price,sd.Amount,p.Name as ProductName,p.Price as ProductPrice,p.BoxQty,c.FirmName as PartyName,c.PersonName,c.VATTin as BuyersVatTinNo,c.CSTTin as BuyersCstTinNo,m.Name from SalesDetails sd inner join SalesForm s on s.ID=sd.SalesForm inner join MstProduct p on p.ID=sd.Product inner join MstCustomer c on c.ID=s.Customer inner join MstMainCategory m on m.ID=p.MainCategory where s.ID=" + txtBill.Text + "", con);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmdSelectItems;
DataTable dtItems = new DataTable();
sda.Fill(dtItems);
SrNo = 1;
for (int i = 0; i < dtItems.Rows.Count; i++)
{
ProductName = dtItems.Rows[i][14].ToString();
ProductRate = dtItems.Rows[i][15].ToString();
ProductQuantity = dtItems.Rows[i][09].ToString();
ProductNumberOfBox = dtItems.Rows[i][11].ToString();
ProductAmount = dtItems.Rows[i][13].ToString();
//description Data
PdfPCell nestedTableCell20 = new PdfPCell(new iTextSharp.text.Paragraph("" + SrNo + "", MainTextRegularSmall));
nestedTableCell20.HorizontalAlignment = 1;
nestedTableCell20.BorderWidthTop = 0;
nestedTableCell20.BorderWidthLeft = 0;
nestedTableCell20.BorderWidthRight = 1;
nestedTableCell20.BorderWidthBottom = 0;
PdfPCell nestedTableCell21 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductName + "", MainTextRegularSmall));
nestedTableCell21.HorizontalAlignment = 1;
nestedTableCell21.BorderWidthTop = 0;
nestedTableCell21.BorderWidthLeft = 0;
nestedTableCell21.BorderWidthRight = 1;
nestedTableCell21.BorderWidthBottom = 0;
PdfPCell nestedTableCell22 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductRate + "", MainTextRegularSmall));
nestedTableCell22.HorizontalAlignment = 1;
nestedTableCell22.BorderWidthTop = 0;
nestedTableCell22.BorderWidthLeft = 0;
nestedTableCell22.BorderWidthRight = 1;
nestedTableCell22.BorderWidthBottom = 0;
PdfPCell nestedTableCell23 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductQuantity + "", MainTextRegularSmall));
nestedTableCell23.HorizontalAlignment = 2;
nestedTableCell23.BorderWidthTop = 0;
nestedTableCell23.BorderWidthLeft = 0;
nestedTableCell23.BorderWidthRight = 1;
nestedTableCell23.BorderWidthBottom = 0;
PdfPCell nestedTableCell24 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductNumberOfBox + "", MainTextRegularSmall));
nestedTableCell24.HorizontalAlignment = 2;
nestedTableCell24.BorderWidthTop = 0;
nestedTableCell24.BorderWidthLeft = 0;
nestedTableCell24.BorderWidthRight = 0;
nestedTableCell24.BorderWidthBottom = 0;
PdfPCell nestedTableCell25 = new PdfPCell(new iTextSharp.text.Paragraph("" + ProductAmount + "", MainTextRegularSmall));
nestedTableCell25.HorizontalAlignment = 2;
nestedTableCell25.BorderWidthTop = 0;
nestedTableCell25.BorderWidthLeft = 1;
nestedTableCell25.BorderWidthRight = 1;
nestedTableCell25.BorderWidthBottom = 0;
nestedTable.AddCell(nestedTableCell20);
nestedTable.AddCell(nestedTableCell21);
nestedTable.AddCell(nestedTableCell22);
nestedTable.AddCell(nestedTableCell23);
nestedTable.AddCell(nestedTableCell24);
nestedTable.AddCell(nestedTableCell25);
SrNo++;
}
PdfPCell nestedTableCell_20 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_20.HorizontalAlignment = 1;
nestedTableCell_20.BorderWidthTop = 0;
nestedTableCell_20.BorderWidthLeft = 0;
nestedTableCell_20.BorderWidthRight = 1;
nestedTableCell_20.BorderWidthBottom = 1;
PdfPCell nestedTableCell_21 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_21.HorizontalAlignment = 1;
nestedTableCell_21.BorderWidthTop = 0;
nestedTableCell_21.BorderWidthLeft = 0;
nestedTableCell_21.BorderWidthRight = 1;
nestedTableCell_21.BorderWidthBottom = 1;
PdfPCell nestedTableCell_22 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_22.HorizontalAlignment = 1;
nestedTableCell_22.BorderWidthTop = 0;
nestedTableCell_22.BorderWidthLeft = 0;
nestedTableCell_22.BorderWidthRight = 1;
nestedTableCell_22.BorderWidthBottom = 1;
PdfPCell nestedTableCell_23 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_23.HorizontalAlignment = 2;
nestedTableCell_23.BorderWidthTop = 0;
nestedTableCell_23.BorderWidthLeft = 0;
nestedTableCell_23.BorderWidthRight = 1;
nestedTableCell_23.BorderWidthBottom = 1;
PdfPCell nestedTableCell_24 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_24.HorizontalAlignment = 2;
nestedTableCell_24.BorderWidthTop = 0;
nestedTableCell_24.BorderWidthLeft = 0;
nestedTableCell_24.BorderWidthRight = 0;
nestedTableCell_24.BorderWidthBottom = 1;
PdfPCell nestedTableCell_25 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell_25.HorizontalAlignment = 2;
nestedTableCell_25.BorderWidthTop = 0;
nestedTableCell_25.BorderWidthLeft = 1;
nestedTableCell_25.BorderWidthRight = 1;
nestedTableCell_25.BorderWidthBottom = 1;
nestedTable.AddCell(nestedTableCell_20);
nestedTable.AddCell(nestedTableCell_21);
nestedTable.AddCell(nestedTableCell_22);
nestedTable.AddCell(nestedTableCell_23);
nestedTable.AddCell(nestedTableCell_24);
nestedTable.AddCell(nestedTableCell_25);
//calculation i.e discount, vat ***********************
PdfPCell nestedTableCell20_1 = new PdfPCell(new iTextSharp.text.Paragraph("\nTOTAL\n\n", MainTextRegularBold));
nestedTableCell20_1.HorizontalAlignment = 1;
nestedTableCell20_1.Colspan = 3;
nestedTableCell20_1.BorderWidthTop = 0;
nestedTableCell20_1.BorderWidthLeft = 1;
nestedTableCell20_1.BorderWidthRight = 1;
nestedTableCell20_1.BorderWidthBottom = 0;
PdfPCell nestedTableCell23_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + TotalQuantity + "\n\n", MainTextRegularSmall));
nestedTableCell23_1.HorizontalAlignment = 2;
nestedTableCell23_1.BorderWidthBottom = 0;
nestedTableCell23_1.BorderWidthTop = 0;
nestedTableCell23_1.BorderWidthLeft = 0;
nestedTableCell23_1.BorderWidthRight = 1;
PdfPCell nestedTableCell24_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + TotalBoxes + "\n\n", MainTextRegularSmall));
nestedTableCell24_1.HorizontalAlignment = 2;
nestedTableCell24_1.BorderWidth = 1;
nestedTableCell24_1.BorderWidthTop = 0;
nestedTableCell24_1.BorderWidthLeft = 0;
nestedTableCell24_1.BorderWidthRight = 0;
nestedTableCell24_1.BorderWidthBottom = 0;
PdfPCell nestedTableCell25_1 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + ItemTotalAmount + "\n\n", MainTextRegularSmall));
nestedTableCell25_1.HorizontalAlignment = 2;
nestedTableCell25_1.BorderWidth = 1;
nestedTableCell25_1.BorderWidthTop = 0;
nestedTableCell25_1.BorderWidthLeft = 1;
nestedTableCell25_1.BorderWidthBottom = 0;
nestedTable.AddCell(nestedTableCell20_1);
nestedTable.AddCell(nestedTableCell23_1);
nestedTable.AddCell(nestedTableCell24_1);
nestedTable.AddCell(nestedTableCell25_1);
PdfPCell nestedTableCell26 = new PdfPCell(new iTextSharp.text.Paragraph("Total Amount in words:" + AmountInWords + "", MainTextRegularSmall));
nestedTableCell26.HorizontalAlignment = Element.ALIGN_LEFT;
nestedTableCell26.Colspan = 4;
//nestedTableCell26.Rowspan = 4;
nestedTableCell26.BorderWidthTop = 1;
nestedTableCell26.BorderWidthLeft = 1;
nestedTableCell26.BorderWidthRight = 1;
nestedTableCell26.BorderWidthBottom = 0;
PdfPCell nestedTableCell28 = new PdfPCell(new iTextSharp.text.Paragraph("\n(-)Discount " + DiscountRate + "%\n\n", MainTextRegularSmall));
nestedTableCell28.HorizontalAlignment = 2;
nestedTableCell28.BorderWidthLeft = 0;
nestedTableCell28.BorderWidthRight = 0;
nestedTableCell28.BorderWidthBottom = 0;
nestedTableCell28.BorderWidthTop = 1;
PdfPCell nestedTableCell29 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + DiscountAmount + "\n\n", MainTextRegularSmall));
nestedTableCell29.HorizontalAlignment = 2;
nestedTableCell29.BorderWidth = 1;
nestedTableCell29.BorderWidthRight = 1;
nestedTableCell29.BorderWidthBottom = 0;
nestedTableCell29.BorderWidthLeft = 1;
nestedTable.AddCell(nestedTableCell26);
nestedTable.AddCell(nestedTableCell28);
nestedTable.AddCell(nestedTableCell29);
PdfPCell nestedTable_Cell30 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularSmall));
nestedTable_Cell30.HorizontalAlignment = 2;
nestedTable_Cell30.BorderWidthTop = 1;
nestedTable_Cell30.BorderWidthRight = 1;
nestedTable_Cell30.BorderWidthBottom = 0;
nestedTable_Cell30.BorderWidthLeft = 1;
nestedTable_Cell30.Colspan = 4;
nestedTable_Cell30.Rowspan = 2;
PdfPTable nestedTableFornestedTable_Cell30 = new PdfPTable(new float[] { 50f, 50f });
nestedTableFornestedTable_Cell30.TotalWidth = 278f;
nestedTableFornestedTable_Cell30.LockedWidth = true;
nestedTableFornestedTable_Cell30.HorizontalAlignment = Element.ALIGN_LEFT;
nestedTableFornestedTable_Cell30.SpacingBefore = 2f;
nestedTableFornestedTable_Cell30.SpacingAfter = 4f;
Phrase pBVatTin = new Phrase();
Chunk c1 = new Chunk("Buyer's VAT Tin", MainTextRegularSmallBold);
Chunk c2 = new Chunk(": " + BuyersVatTinNo + "\n", MainTextRegularSmall);
pBVatTin.Add(c1);
pBVatTin.Add(c2);
PdfPCell nestedTableFornestedTable_Cell30_Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(""));
nestedTableFornestedTable_Cell30_Cell01.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthTop = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell01.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell01.AddElement(pBVatTin);
Phrase pBCstTin = new Phrase();
Chunk c3 = new Chunk("Buyer's CST Tin", MainTextRegularSmallBold);
Chunk c4 = new Chunk(": " + BuyersCstTinNo + "", MainTextRegularSmall);
pBCstTin.Add(c3);
pBCstTin.Add(c4);
PdfPCell nestedTableFornestedTable_Cell30_Cell02 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell02.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidth = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell02.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell02.AddElement(pBCstTin);
Phrase pSVatTin = new Phrase();
Chunk c5 = new Chunk("Seller's VAT Tin", MainTextRegularSmallBold);
Chunk c6 = new Chunk(": " + SellerVatTinNo + "", MainTextRegularSmall);
pSVatTin.Add(c5);
pSVatTin.Add(c6);
PdfPCell nestedTableFornestedTable_Cell30_Cell03 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell03.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthTop = 1;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell03.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell03.AddElement(pSVatTin);
Phrase pSCstTin = new Phrase();
Chunk c7 = new Chunk("Seller's CST Tin", MainTextRegularSmallBold);
Chunk c8 = new Chunk(": " + SellerCstTinNo + "", MainTextRegularSmall);
pSCstTin.Add(c7);
pSCstTin.Add(c8);
PdfPCell nestedTableFornestedTable_Cell30_Cell04 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableFornestedTable_Cell30_Cell04.HorizontalAlignment = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthTop = 1;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthRight = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthBottom = 0;
nestedTableFornestedTable_Cell30_Cell04.BorderWidthLeft = 0;
nestedTableFornestedTable_Cell30_Cell04.AddElement(pSCstTin);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell01);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell02);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell03);
nestedTableFornestedTable_Cell30.AddCell(nestedTableFornestedTable_Cell30_Cell04);
nestedTable_Cell30.AddElement(nestedTableFornestedTable_Cell30);
PdfPCell nestedTableCell30 = new PdfPCell(new iTextSharp.text.Paragraph("Total ", MainTextRegularSmall));
nestedTableCell30.HorizontalAlignment = 2;
nestedTableCell30.VerticalAlignment = Element.ALIGN_MIDDLE;
nestedTableCell30.BorderWidthTop = 1;
nestedTableCell30.BorderWidthRight = 0;
nestedTableCell30.BorderWidthBottom = 1;
nestedTableCell30.BorderWidthLeft = 0;
PdfPCell nestedTableCell31 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + WithDicoount_TotalAmount + "\n\n", MainTextRegularSmall));
nestedTableCell31.HorizontalAlignment = 2;
nestedTableCell31.BorderWidthTop = 1;
nestedTableCell31.BorderWidthRight = 1;
nestedTableCell31.BorderWidthBottom = 1;
nestedTableCell31.BorderWidthLeft = 1;
nestedTable.AddCell(nestedTable_Cell30);
nestedTable.AddCell(nestedTableCell30);
nestedTable.AddCell(nestedTableCell31);
PdfPCell nestedTable_Cell32 = new PdfPCell(new iTextSharp.text.Paragraph(" I/We hereby certify that my/our registration certificate under the Maharashtra Value Addess Tax Act.2002 is in force on the date on which the sale of goods specified in this 'Tax Invoice' is made by me/us and that the transaction of sale covered by this 'Tax Invoice' has been effected by me/us and it shall be accounted for in the turn over of sales while fililng return and due tax, if any payable on the sales has been paid shall be paid.\n\n\n\n\n*T&c apply", MainTextRegularSmall));
nestedTable_Cell32.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
nestedTable_Cell32.VerticalAlignment = Element.ALIGN_TOP;
nestedTable_Cell32.BorderWidthTop = 1;
nestedTable_Cell32.BorderWidthRight = 1;
nestedTable_Cell32.BorderWidthBottom = 0;
nestedTable_Cell32.BorderWidthLeft = 1;
nestedTable_Cell32.Colspan = 4;
nestedTable_Cell32.Rowspan = 5;
PdfPCell nestedTableCell32 = new PdfPCell(new iTextSharp.text.Paragraph("\n(+)Vat " + VatRate + "%\n\n", MainTextRegularSmall));
nestedTableCell32.HorizontalAlignment = 2;
nestedTableCell32.BorderWidthTop = 0;
nestedTableCell32.BorderWidthRight = 0;
nestedTableCell32.BorderWidthBottom = 0;
nestedTableCell32.BorderWidthLeft = 0;
PdfPCell nestedTableCell33 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + VatAmount + "\n\n", MainTextRegularSmall));
nestedTableCell33.HorizontalAlignment = 2;
nestedTableCell33.BorderWidthTop = 0;
nestedTableCell33.BorderWidthRight = 1;
nestedTableCell33.BorderWidthBottom = 0;
nestedTableCell33.BorderWidthLeft = 1;
//nestedTable.AddCell(nestedTable_Cell32);
nestedTable.AddCell(nestedTableCell32);
nestedTable.AddCell(nestedTableCell33);
//PdfPCell nestedTable_Cell34 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
//nestedTable_Cell34.HorizontalAlignment = 2;
//nestedTable_Cell34.BorderWidthTop = 1;
//nestedTable_Cell34.BorderWidthRight = 0;
//nestedTable_Cell34.BorderWidthBottom = 0;
//nestedTable_Cell34.BorderWidthLeft = 1;
//nestedTable_Cell34.Colspan = 4;
PdfPCell nestedTableCell34 = new PdfPCell(new iTextSharp.text.Paragraph("GrandTotal", MainTextRegularSmall));
nestedTableCell34.HorizontalAlignment = 2;
nestedTableCell34.VerticalAlignment = Element.ALIGN_MIDDLE;
nestedTableCell34.BorderWidthTop = 1;
nestedTableCell34.BorderWidthRight = 0;
nestedTableCell34.BorderWidthBottom = 1;
nestedTableCell34.BorderWidthLeft = 0;
PdfPCell nestedTableCell35 = new PdfPCell(new iTextSharp.text.Paragraph("\n" + WithVat_GrandTotal + "\n\n", MainTextRegularSmall));
nestedTableCell35.HorizontalAlignment = 2;
nestedTableCell35.BorderWidthTop = 1;
nestedTableCell35.BorderWidthRight = 1;
nestedTableCell35.BorderWidthBottom = 1;
nestedTableCell35.BorderWidthLeft = 1;
nestedTable.AddCell(nestedTable_Cell32);
nestedTable.AddCell(nestedTableCell34);
nestedTable.AddCell(nestedTableCell35);
//created row for vattin no
//PdfPCell nestedTableCell36 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
//nestedTableCell36.HorizontalAlignment = 2;
//nestedTableCell36.BorderWidth = 1;
//nestedTableCell36.Colspan = 3;
//PdfPTable nestedTableForCell36 = new PdfPTable(new float[] { 44f,56f });
//nestedTableForCell36.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
//nestedTableForCell36.TotalWidth = 170f;
//nestedTableForCell36.LockedWidth = true;
//nestedTableForCell36.HorizontalAlignment = Element.ALIGN_LEFT;
//nestedTableForCell36.SpacingBefore = 0f;
//PdfPCell nestedTableForCell36Cell01 = new PdfPCell(new iTextSharp.text.Paragraph("Buyer's VATtin No", MainTextRegularBold));
//nestedTableForCell36Cell01.HorizontalAlignment = 0;
//nestedTableForCell36Cell01.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(": ", MainTextRegularSmall));
//nestedTableForCell36Cell02.HorizontalAlignment = 1;
//nestedTableForCell36Cell02.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("Seller's VATtin No", MainTextRegularBold));
//nestedTableForCell36Cell03.HorizontalAlignment = 0;
//nestedTableForCell36Cell03.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell04 = new PdfPCell(new iTextSharp.text.Paragraph(": ", MainTextRegularSmall));
//nestedTableForCell36Cell04.HorizontalAlignment = 1;
//nestedTableForCell36Cell04.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell05 = new PdfPCell(new iTextSharp.text.Paragraph("CST TIN No", MainTextRegularBold));
//nestedTableForCell36Cell05.HorizontalAlignment = 0;
//nestedTableForCell36Cell05.BorderWidth = 0;
//PdfPCell nestedTableForCell36Cell06 = new PdfPCell(new iTextSharp.text.Paragraph(": ", MainTextRegularSmall));
//nestedTableForCell36Cell06.HorizontalAlignment = 1;
//nestedTableForCell36Cell06.BorderWidth = 0;
//nestedTableForCell36.AddCell(nestedTableForCell36Cell01);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell02);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell03);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell04);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell05);
//nestedTableForCell36.AddCell(nestedTableForCell36Cell06);
//nestedTableCell36.AddElement(nestedTableForCell36);
//nestedTable.AddCell(nestedTableCell36);
PdfPCell nestedTableCell37 = new PdfPCell(new iTextSharp.text.Paragraph("", MainTextRegularBold));
nestedTableCell37.HorizontalAlignment = 0;
nestedTableCell37.BorderWidth = 1;
nestedTableCell37.Colspan = 3;
//nestedTable.AddCell(nestedTableCell37);
//Terms and conditions
//created row for vattin no
PdfPCell nestedTableCell38 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularSmall));
nestedTableCell38.HorizontalAlignment = 2;
nestedTableCell38.BorderWidth = 0;
nestedTableCell38.Colspan = 4;
PdfPTable nestedTableForCell38 = new PdfPTable(new float[] { 100f });
nestedTableForCell38.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
nestedTableForCell38.TotalWidth = 400f;
nestedTableForCell38.LockedWidth = true;
nestedTableForCell38.HorizontalAlignment = Element.ALIGN_LEFT;
PdfPCell nestedTableForCell38Cell01 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularBold));
nestedTableForCell38Cell01.HorizontalAlignment = 0;
nestedTableForCell38Cell01.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell02 = new PdfPCell(new iTextSharp.text.Paragraph(" ", MainTextRegularExtraSmall));//terms 1. RATES ARE QUOTED EX-FACTORY BASIS.
nestedTableForCell38Cell02.HorizontalAlignment = 0;
nestedTableForCell38Cell02.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell03 = new PdfPCell(new iTextSharp.text.Paragraph("2. VAT TAX 5%, TRANSPORT AND OCTROI WILL BE CHARGED EXTRA IF APPLICABLE.", MainTextRegularExtraSmall));
nestedTableForCell38Cell03.HorizontalAlignment = 0;
nestedTableForCell38Cell03.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell04 = new PdfPCell(new iTextSharp.text.Paragraph("3. GOODS WILL BE DISPATCHED WITHIN 8 DAYS AFTER RECEIVING COMPLETE PAYMENT WITH PO.", MainTextRegularExtraSmall));
nestedTableForCell38Cell04.HorizontalAlignment = 0;
nestedTableForCell38Cell04.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell05 = new PdfPCell(new iTextSharp.text.Paragraph("4. REPLACEMENT AND UNSOLD MATERIAL WILL NOT BE TAKEN BACK OR INTERTAINED.", MainTextRegularExtraSmall));
nestedTableForCell38Cell05.HorizontalAlignment = 0;
nestedTableForCell38Cell05.BorderWidth = 0;
PdfPCell nestedTableForCell38Cell06 = new PdfPCell(new iTextSharp.text.Paragraph("5. CHANGES IN PRICE LIST RESERVED WITH THE COMPANY.", MainTextRegularExtraSmall));
nestedTableForCell38Cell06.HorizontalAlignment = 0;
nestedTableForCell38Cell06.BorderWidth = 0;
nestedTableForCell38.AddCell(nestedTableForCell38Cell01);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell02);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell03);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell04);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell05);
//nestedTableForCell38.AddCell(nestedTableForCell38Cell06);
//nestedTableCell38.AddElement(nestedTableForCell38);
nestedTable.AddCell(nestedTableCell38);
PdfPCell nestedTableCell39 = new PdfPCell(new iTextSharp.text.Paragraph("FOR MAGANLAL CHIKKI", MainTextRegularSmallBold));
nestedTableCell39.HorizontalAlignment = 2;
nestedTableCell39.BorderWidth = 0;
nestedTableCell39.Colspan = 2;
nestedTable.AddCell(nestedTableCell39);
PdfPCell nestedTableCell40 = new PdfPCell(new iTextSharp.text.Paragraph("\n\n\n(Propritor/Auth. Signature)", MainTextRegularSmallBold));
nestedTableCell40.HorizontalAlignment = 2;
nestedTableCell40.BorderWidth = 0;
nestedTableCell40.Colspan = 2;
nestedTable.AddCell(nestedTableCell40);
MainTableCell1.AddElement(nestedTable);
MainTable.AddCell(MainTableCell1);
//print main data is over
MasterMainTable_Cell01.AddElement(MainTable);
MasterMainTable_Cell02.AddElement(MainTable);
MasterMainTable.AddCell(MasterMainTable_Cell01);
MasterMainTable.AddCell(MasterMainTable_SpaceCell);
MasterMainTable.AddCell(MasterMainTable_Cell02);
pdfDoc.Add(MasterMainTable);
pdfDoc.Close();
//HttpContext.Current.Response.ContentType = "application/pdf";
//HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
//HttpContext.Current.Response.Write(pdfDoc);
//HttpContext.Current.Response.End();
//pdfDoc.Close();
//Response.ContentType = "application/pdf";
//Response.AddHeader("content-disposition", "attachment;filename=c:\abc.pdf");
//Response.Cache.SetCacheability(HttpCacheability.NoCache);
//Response.Write(pdfDoc);
//Response.End();
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=c:\abc.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.Redirect(Request.Url.AbsoluteUri);
Response.End();
//string urlName = Request.Url.AbsoluteUri;
//urlName = urlName.Remove(urlName.LastIndexOf("/"));
////Adding FolderName and FileName in the URL
//string url21 = string.Format("pdfDoc", urlName);
//string script = "<script type='text/javascript'>window.open('" + url21 + "')</script>";
//this.ClientScript.RegisterStartupScript(this.pdfDoc.pdf, "script", script);
//string url11 = string.Format("SalesBill.aspx?FN={0}.pdf", (sender as LinkButton).CommandArgument);
//string script = "<script type='text/javascript'>window.open('" + url11 + "')</script>";
//this.ClientScript.RegisterStartupScript(this.GetType(), "script", script);
//string filePath = Server.MapPath("~/Reports/") + Request.QueryString["FN"];
//this.Response.ContentType = "application/pdf";
//this.Response.AppendHeader("Content-Disposition;", "attachment;filename=" + Request.QueryString["FN"]);
//this.Response.WriteFile(filePath);
//this.Response.End();
//Response.ContentType = "Application/pdf";
//Response.TransmitFile(pathtofile);
//Response.BinaryWrite(PdfFileByteArray);
//Response.End();
//Response.Write(pdfDoc);
//Response.End();
//string filePath = Server.MapPath("~/Reports/") + Request.QueryString["FN"];
//this.Response.ContentType = "application/pdf";
//this.Response.AppendHeader("Content-Disposition;", "attachment;filename=" + Request.QueryString["FN"]);
//this.Response.WriteFile(filePath);
//this.Response.End();
#endregion
}
protected void btnPrint_Click(object sender, EventArgs e)
{
PrintBill();
}
protected void btnPrintSailsBill_Click(object sender, EventArgs e)
{
PrintBill_WithOutBorder();
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
PrintBill_WithOutBorder();
}
}