locked
How to fetch and print to screen over 5000 Customer invoice without Timeout Or Server not responding on internet Connection RRS feed

  • Question

  • User2085798977 posted

    Hello,

    Please i your professional advice and way to fetch and print to screen over 5000 Customer invoice with Timeout Or Server not responding on internet Connection.

    Am working on billing web application which involve in fetch and print to screen over 5000 Customer invoice over the internet to print from the printer. but have been having problem of Timeout Or Server not responding on internet Connection.

    Please help i need to get this right. both on slow and fast internet speed connection

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PrintInv2.aspx.cs" Inherits="PrintInv2" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <%@ Import Namespace="System.Globalization" %>
    <script language="C#" runat="server">
        private readonly SqlConnection _Cnndb = new SqlConnection(GetContent.ConnectDB());
        public DateTime LastMonth = Convert.ToDateTime(string.Format("{0}-{1}-{2}", DateTime.Today.ToString("yyyy"), DateTime.Today.ToString("MM"), "01")).AddMonths(-1);
    
        private string _dStreet;
        private string _dHouseNo;
        private string _dDataHouse;
        private string _dOccupant;
        private string _dlga;
        private string _dDescription;
        private int _dNoOfRooms;
        private string _dTotAmount;
        private int _dtAmount;
        private int _dtAMonth;
        private DateTime _dPaymentDate;
        private int _dLastPaid;
        private int _dateDiff;
        private int _toPayNow;
        private int _asDueNow;
        private int _dbTrue;
        private int _count;
        private int _asPreDue;
        private int _asSumChk;
        private int _dtGb;
        private int _dtGpb;
        private string _dInvoiceNumber, _dPaymentType;
        protected string DBillingMonth;
        protected string DBillingYear;
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
            <title></title>
        </head>
        <body>
            <form id="form1" runat="server">
                <div>
                    <asp:Label ID="DStatus" runat="server" Font-Bold="True" Style="color: Green; font-size: ;" />
                    <asp:Label ID="DError" runat="server" Style="color: Red; font-size: ;" />
                    <p>
                        <br />
                    </p>
                    <div align="center">
                        <%
                            _Cnndb.Open();
                            SqlCommand getBillCmd = _Cnndb.CreateCommand();
                            getBillCmd.CommandText = string.Format("SELECT DISTINCT cb.HouseCode, cb.InvoiceNumber, cb.Street, cb.Occupant, cb.LGA, cd.HouseNo, cd.NoOfRooms, cd.Description, cb.BillingMonth, cb.BillingYear, cb.MonthlyTariff, cb.PreBalance, cb.SumBalance, cb.LastPaid, cb.PaymentType, cb.PaymentDate FROM PrintBills cb INNER JOIN CustomerData cd ON cb.HouseCode = cd.HouseCode WHERE (cb.PrintStatus IS NULL AND cb.ZoneName = '{0}' OR cb.HouseCode = '{0}' OR cb.Occupant = '{0}' OR cb.Street = '{0}') AND (cb.Domain = '{1}' OR cb.Domain = '{2}') AND cb.BillingMonth = '{3}' AND cb.BillingYear = '{4}' ORDER BY cb.Street ASC", Request.QueryString["ord"], Request.QueryString["DPSP"], Session["companyname"], Convert.ToString(Request.QueryString["arg"]), Convert.ToInt32(Request.QueryString["arg2"]));
                            SqlDataReader rdBill = getBillCmd.ExecuteReader();
    
                            while (rdBill.Read())
                            {
                                _dDataHouse = (string) rdBill["HouseCode"];
                                _dStreet = (string) rdBill["Street"];
                                _dHouseNo = (string) rdBill["HouseNo"];
                                _dOccupant = (string) rdBill["Occupant"];
                                DBillingMonth = (string) rdBill["BillingMonth"];
                                DBillingYear = (string) rdBill["BillingYear"];
                                _dlga = (string) rdBill["LGA"];
                                _dNoOfRooms = (int) rdBill["NoOfRooms"];
                                _dInvoiceNumber = (string) rdBill["InvoiceNumber"];
                                _dPaymentType = (string) rdBill["PaymentType"];
                                _dtAmount = (int) rdBill["MonthlyTariff"];
                                _asPreDue = (int) rdBill["PreBalance"];
                                _asDueNow = (int) rdBill["SumBalance"];
                                _dLastPaid = (int) rdBill["LastPaid"];
                                _dPaymentDate = (DateTime) rdBill["PaymentDate"];
    
                                _dTotAmount = string.Format("{0:C}", _dtAmount.ToString("C", CultureInfo.CurrentCulture).Replace("$", ""));
                                _dDescription = rdBill["Description"] != DBNull.Value ? (string) rdBill["Description"] : "";
    
                                string strAmountWords = Convert.ToString(_asDueNow).Replace("-", "");
                                _count = _count + 1;
                                _toPayNow = _asDueNow;
                        %>
                            <table align="center" border="1">
                                <tr>
                                    <td>
                                        <table width="880" height="100" border="0" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td width="345" height="159" align="left" valign="top">
                                                    <table width="345" height="150" border="0" cellpadding="0" cellspacing="0">
                                                        <tr>
                                                            <td height="21" valign="bottom" class="font3" style="font-size: 18px; font-weight: bolder; text-transform: capitalize">Your Bill</td>
                                                        </tr>
                                                        <tr>
                                                            <td height="108">
                                                                <table width="322" height="85" border="0" cellpadding="0" cellspacing="0">
                                                                    <tr>
                                                                        <td width="71" align="left" class="font1">NAME:
                                                                        </td>
                                                                        <td width="251">
                                                                            <small>
                                                                                <%= _dOccupant %></small>&nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="left" class="font1">ADDRESS:
                                                                        </td>
                                                                        <td>
                                                                            <small>
                                                                                <%= _dHouseNo %>&nbsp;&nbsp;&nbsp;<%= _dStreet %></small>&nbsp;
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td align="left" class="font1">L.G.A.
                                                                        </td>
                                                                        <td>
                                                                            <small>
                                                                                <%= _dlga %></small>&nbsp;
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
    
                                                    </table>
                                                </td>
                                                <td width="535" align="right" valign="middle">
                                                    <form id="form2" name="form1" method="post" action="">
                                                        <table width="400" border="0" align="right" cellpadding="0" cellspacing="0">
                                                            <tr>
                                                                <td height="30" valign="bottom">
                                                                    <center><b style="font-size: 20px; font-weight: bolder; text-transform: capitalize"><%--<%=_cDomain %>--%><%= Request.QueryString["DPSP"] %></b></center>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td height="32" valign="bottom">
                                                                    <table width="402" border="0" cellspacing="0" cellpadding="0">
                                                                        <tr>
                                                                            <td width="18" align="left">
                                                                                <img src="../images/icons/bullet.png" width="14" height="14" /></td>
                                                                            <td width="147" class="font1"><b style="font-size: 12px">Customer Care:</b></td>
                                                                            <td width="259"><small><b></b></small></td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td width="18" align="left">
                                                                                <img src="../images/icons/bullet.png" width="14" height="14" /></td>
                                                                            <td width="147" class="font1"><b style="font-size: 12px">Email:</b></td>
                                                                            <td width="259"><small><b></b></small></td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td width="18" align="left">
                                                                                <img src="../images/icons/bullet.png" width="14" height="14" /></td>
                                                                            <td width="147" class="font1" nowrap="nowrap"><b class="font4" style="color: #000">Account Number:</b></td>
                                                                            <td width="259"><b><%--<%= _accountNumber %>--%><%= Request.QueryString["account"] %></b></td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td align="left">
                                                                                <img src="../images/icons/bullet.png" width="14" height="14" /></td>
                                                                            <td class="font1"><b style="font-size: 12px">Invoice No:</b></td>
                                                                            <td><small><b><%= _dInvoiceNumber %></b></small>&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td width="19" align="left">
                                                                                <img src="../images/icons/bullet.png" width="14" height="14" /></td>
                                                                            <td width="156" nowrap="nowrap"><b style="font-size: 12px">Bill Reference HouseCode:</b></td>
                                                                            <td width="227" nowrap="nowrap"><small><b><%= Session["HouseCode"] %></b></small></td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td align="left">
                                                                                <img src="../images/icons/bullet.png" width="14" height="14" /></td>
                                                                            <td class="font1"><b style="font-size: 12px">Invoice/Date:</b></td>
                                                                            <td><small><b><%= DateTime.Today.ToString("yyyy-MM-dd") %></b></small>&nbsp;</td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td height="65" valign="middle" style="font-size: 18px; font-weight: bolder; text-transform: capitalize">Let us make
                                                                    &nbsp;
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </form>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top">
                                        <table width="878" border="1" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <th width="270" height="24" align="center">
                                                    <div align="center">
                                                        Description of property
                                                    </div>
                                                </th>
                                                <th width="200" align="center" nowrap="nowrap">
                                                    <div align="center">
                                                        Unit price
                                                    </div>
                                                </th>
                                                <th width="200" align="center" nowrap="nowrap">
                                                    <div align="center">
                                                        Total
                                                    </div>
                                                </th>
                                            </tr>
                                            <tr>
                                                <td height="19" align="center">
                                                    <small>Previous Balance</small>
                                                </td>
                                                <td class="border_l">&nbsp;
                                                </td>
                                                <td align="center" nowrap="nowrap">
                                                    <small>
                                                        <center>
                                                            <%= string.Format("{0:c}", _asPreDue).Replace("$", "₦") %>
                                                        </center>
                                                    </small>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="19" align="center">
                                                    <small>
                                                        <% if (_dPaymentType == "REBATED")
                                                           { %>
                                                            Rebated Amount
                                                        <% }
                                                           else
                                                           { %>
                                                            Last Payment
                                                        <% } %>
                                                        <% if (_dLastPaid != 0)
                                                           { %> -<%= string.Format("{0:D}", _dPaymentDate) %><% } %>
                                                    </small>
                                                </td>
                                                <td class="border_l">&nbsp;
                                                </td>
                                                <td align="center" nowrap="nowrap">
                                                    <small>
                                                        <center>
                                                            <% if (_dLastPaid != 0)
                                                               { %>
                                                                (<%= string.Format("{0:C}", _dLastPaid).Replace("$", "₦") %>)
                                                                                       
                                                            <% }
                                                               else
                                                               { %>
                                                                (-)
                                                            <% } %>
                                                        </center>
                                                        <%-- <center>
                                                                                    <%if (_dLastPaid != 0)
                                                                                      {
                                                                                          if (_dPaymentDate > LastMonth)
                                                                                          { %>
                                                                                    
                                                                                        (<%= string.Format("{0:C}", _dLastPaid.ToString().Replace("$", "")) %>)
                                                                                        <% }else
                                                                                          {%>
                                                                                            (-)
                                                                                        <% } %>
                                                                                       
                                                                                     <%}
                                                                                              else
                                                                                              {%>
                                                                                        (-)
                                                                                        <%}%>
                                                                                </center>--%>
                                                    </small>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="10" align="center" nowrap="nowrap">
                                                    <small>Bill For The Month Of&nbsp;<%= DBillingMonth %>&nbsp;-&nbsp;<%= Convert.ToInt32(Request.QueryString["arg2"]) %><br />
                                                        <%
                                                        %>
                                                        Monthly Charges For: &nbsp;&nbsp;&nbsp;<%= _dNoOfRooms %>&nbsp;<%= _dDescription %>
                                                        &nbsp;&nbsp;<%= _dTotAmount %><br />
                                                        <%
                                                        %>
                                                    </small>
                                                </td>
                                                <td class="border_l">&nbsp;
                                                </td>
                                                <td align="center">
                                                    <center> <small>
                                                                 <%= string.Format("{0:C}", _dTotAmount).Replace("$", "₦") %></small></center>
                                                </td>
                                            </tr>
                                            <%
                                            %>
                                            <p>
                                                &nbsp;
                                            </p>
                                            <%
                                            %>
                                            <tr>
                                                <td height="10" align="center" class="style1">
                                                    <small>Total Due Now</small>
                                                </td>
                                                <td align="center" class="font4">&nbsp;
                                                </td>
                                                <td align="center" class="font4" nowrap="nowrap">
                                                    <center> <b><small>
                                                                    <%= string.Format("{0:C}", _asDueNow).Replace("$", "₦").Replace("(", "-").Replace(")", "") %>
                                                                </small></b>
                                                    </center>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                            <br/>
                            <br/>
                        <% } %>
                    </div>
                </div>
            </form>
        </body>
    </html>

    Thanks

    Tuesday, November 11, 2014 11:32 AM

All replies