Thursday, November 21, 2013

Implement Progress bar while processing

<asp:UpdateProgress ID="uprgchild" runat="server" AssociatedUpdatePanelID="updPnl"
            DisplayAfter="0" DynamicLayout="false">
            <ProgressTemplate>
                <div align="center" class="overlay">
                    <img src="../Images/buyBack-ajax-loader.gif" class="loader"/>
                    </div>
            </ProgressTemplate>


AssociatedUpdatePanelID="updPnl"  : would be update panel ID


and implement this css for above feature :

.overlay {
        position: fixed;
        z-index: 99;
        top: 0px;
        left: 0px;  
    }
    * html .overlay {
        position: absolute;
        height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
        width: expression(document.body.scrollWidth > document.body.offsetWidth ? document.body.scrollWidth : document.body.offsetWidth + 'px');
    }
    .loader {
        z-index: 100;
        position: fixed;
        width: 134px;
        margin: 0px 0 0 10px;
        top: 50%;
        left: 50%;
    }
    * html .loader {
        position: absolute;
        margin-top: expression((document.body.scrollHeight / 4) + (0 - parseInt(this.offsetParent.clientHeight / 2) + (document.documentElement && document.documentElement.scrollTop || document.body.scrollTop)) + 'px');
    }
    

Tuesday, November 12, 2013

DateTime.ToString() Patterns

DateTime.ToString() Patterns

All the patterns:

0 MM/dd/yyyy 08/22/2006
1 dddd, dd MMMM yyyy Tuesday, 22 August 2006
2 dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
3 dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
4 dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
5 dddd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM
6 dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
7 MM/dd/yyyy HH:mm 08/22/2006 06:30
8 MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
9 MM/dd/yyyy H:mm 08/22/2006 6:30
10 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
10 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
10 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
11 MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07
12 MMMM dd August 22
13 MMMM dd August 22
14 yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
15 yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
16 ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT
17 ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT
18 yyyy'-'MM'-'dd'T'HH':'mm':'ss 2006-08-22T06:30:07
19 HH:mm 06:30
20 hh:mm tt 06:30 AM
21 H:mm 6:30
22 h:mm tt 6:30 AM
23 HH:mm:ss 06:30:07
24 yyyy'-'MM'-'dd HH':'mm':'ss'Z' 2006-08-22 06:30:07Z
25 dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
26 yyyy MMMM 2006 August
27 yyyy MMMM 2006 August

The patterns for DateTime.ToString ( 'd' ) :

0 MM/dd/yyyy 08/22/2006

The patterns for DateTime.ToString ( 'D' ) :

0 dddd, dd MMMM yyyy Tuesday, 22 August 2006

The patterns for DateTime.ToString ( 'f' ) :

0 dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
1 dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
2 dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
3 dddd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM

The patterns for DateTime.ToString ( 'F' ) :

0 dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07

The patterns for DateTime.ToString ( 'g' ) :

0 MM/dd/yyyy HH:mm 08/22/2006 06:30
1 MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
2 MM/dd/yyyy H:mm 08/22/2006 6:30
3 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM

The patterns for DateTime.ToString ( 'G' ) :

0 MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07

The patterns for DateTime.ToString ( 'm' ) :

0 MMMM dd August 22

The patterns for DateTime.ToString ( 'r' ) :

0 ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT

The patterns for DateTime.ToString ( 's' ) :

0 yyyy'-'MM'-'dd'T'HH':'mm':'ss 2006-08-22T06:30:07

The patterns for DateTime.ToString ( 'u' ) :

0 yyyy'-'MM'-'dd HH':'mm':'ss'Z' 2006-08-22 06:30:07Z

The patterns for DateTime.ToString ( 'U' ) :

0 dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07

The patterns for DateTime.ToString ( 'y' ) :

0 yyyy MMMM 2006 August

Building a custom DateTime.ToString Patterns

The following details the meaning of each pattern character. Note the K and z character.
d Represents the day of the month as a number from 1 through 31. A single-digit day is formatted without a leading zero
dd Represents the day of the month as a number from 01 through 31. A single-digit day is formatted with a leading zero
ddd Represents the abbreviated name of the day of the week (Mon, Tues, Wed etc)
dddd Represents the full name of the day of the week (Monday, Tuesday etc)
h 12-hour clock hour (e.g. 7)
hh 12-hour clock, with a leading 0 (e.g. 07)
H 24-hour clock hour (e.g. 19)
HH 24-hour clock hour, with a leading 0 (e.g. 19)
m Minutes
mm Minutes with a leading zero
M Month number
MM Month number with leading zero
MMM Abbreviated Month Name (e.g. Dec)
MMMM Full month name (e.g. December)
s Seconds
ss Seconds with leading zero
t Abbreviated AM / PM (e.g. A or P)
tt AM / PM (e.g. AM or PM
y Year, no leading zero (e.g. 2001 would be 1)
yy Year, leadin zero (e.g. 2001 would be 01)
yyy Year, (e.g. 2001 would be 2001)
yyyy Year, (e.g. 2001 would be 2001)
K Represents the time zone information of a date and time value (e.g. +05:00)
z With DateTime values, represents the signed offset of the local operating system's time zone from Coordinated Universal Time (UTC), measured in hours. (e.g. +6)
zz As z but with leadin zero (e.g. +06)
zzz With DateTime values, represents the signed offset of the local operating system's time zone from UTC, measured in hours and minutes. (e.g. +06:00)
f Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value.
ff Represents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value.
fff Represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value.
ffff Represents the four most significant digits of the seconds fraction; that is, it represents the ten thousandths of a second in a date and time value. While it is possible to display the ten thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
fffff Represents the five most significant digits of the seconds fraction; that is, it represents the hundred thousandths of a second in a date and time value. While it is possible to display the hundred thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
ffffff Represents the six most significant digits of the seconds fraction; that is, it represents the millionths of a second in a date and time value. While it is possible to display the millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
fffffff Represents the seven most significant digits of the seconds fraction; that is, it represents the ten millionths of a second in a date and time value. While it is possible to display the ten millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
F Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. Nothing is displayed if the digit is zero.
: Represents the time separator defined in the current DateTimeFormatInfo..::.TimeSeparator property. This separator is used to differentiate hours, minutes, and seconds.
/ Represents the date separator defined in the current DateTimeFormatInfo..::.DateSeparator property. This separator is used to differentiate years, months, and days.
" Represents a quoted string (quotation mark). Displays the literal value of any string between two quotation marks ("). Your application should precede each quotation mark with an escape character (\).
' Represents a quoted string (apostrophe). Displays the literal value of any string between two apostrophe (') characters.
%c Represents the result associated with a c custom format specifier, when the custom date and time format string consists solely of that custom format specifier. That is, to use the d, f, F, h, m, s, t, y, z, H, or M custom format specifier by itself, the application should specify %d, %f, %F, %h, %m, %s, %t, %y, %z, %H, or %M. For more information about using a single format specifier, see Using Single Custom Format Specifiers.
||\c || Represents the escape character, and displays the character "c" as a literal when that character is preceded by the escape character (\). To insert the backslash character itself in the result string, the application should use two escape characters ("\\").

Any other character copies any other character to the result string, without affecting formatting. || 

Wednesday, October 30, 2013

java-script for valid email and letters

    <asp:TextBox ID="txtEmail" runat="server" MaxLength="50" Width="197px" meta:resourcekey="txtEmailResource1"
                                                                TabIndex="2" onblur="validateEmail(this);" ></asp:TextBox>




  // For email validation
       

        function validateEmail(emailField) {
            var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

            if (reg.test(emailField.value) == false) {
                // alert('Invalid Email Address');
                emailField.value = '';
                return false;
            }

            return true;

        }




  <asp:TextBox ID="txtFirstNm" runat="server" MaxLength="20" Width="197px" meta:resourcekey="txtFirstNmResource1" onkeypress="return numeralsOnly(event)"></asp:TextBox>

  // for numeric only

         function numeralsOnly(evt) {
             evt = (evt) ? evt : event;
             var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
          ((evt.which) ? evt.which : 0));
             if (charCode > 31 && (charCode < 65 || charCode > 90) &&
          (charCode < 97 || charCode > 122)) {
                // alert("Enter letters only.");
                 return false;
             }
             return true;

   }



Implementing EDI format to sent order info in ASP.NET

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Text;
using System.Configuration;
using System.IO;
using System.Net;
using System.Net.Mail;
using ThisSite.Common;
using System.Web.Routing;
using ThisSite.BSLayer;


public partial class Admin_GenerateEdi : AdminPageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnGenrateEdi_Click(object sender, EventArgs e)
    {
        Int64 lOrderId = Convert.ToInt64(txtEdi.Text.Trim());
        int BTcount = 0;
        Order pOrder = new Order(lOrderId);
        for (int i = 0; i < pOrder.pOBooks.Count; i++)
        {

            if ((pOrder.pOBooks[i].vcSource.ToString().ToUpper() == "BT") && BTcount == 0)
            {
                GnrtOrdForBakerEDI(pOrder);            
                BTcount = BTcount + 1;
            }
        }    
    }

    public  void GnrtOrdForBakerEDI(Order pOrder)
    {
        try
        {
            StringBuilder strBuilder = new StringBuilder();
            int startLine = 0;      
            string DlvryCountry = string.Empty;
            if (pOrder.lDlvryCoutry.HasValue)
            {
                Country pCountry = new Country(Convert.ToInt64(pOrder.lDlvryCoutry.Value));              
                DlvryCountry = pCountry.sISOAlpha2;
            }
            if (pOrder.lDlvryCoutry.HasValue)
            {
                Country pCountry = new Country(Convert.ToInt64(pOrder.lDlvryCoutry.Value));
                //DlvryCountry = pCountry.sCountryNm.Substring(0, 2).ToUpper(); ;
                DlvryCountry = pCountry.sISOAlpha2;
            }
            if (pOrder.lDlvryCoutry.HasValue)
            {
                Country pCountry = new Country(Convert.ToInt64(pOrder.lDlvryCoutry.Value));
                //DlvryCountry = pCountry.sCountryNm.Substring(0, 2).ToUpper(); ;
                DlvryCountry = pCountry.sISOAlpha2;
            }
            string sDlvryStateCode = string.Empty;
            if (!string.IsNullOrEmpty(pOrder.sDlvryStateCode))
            {
                sDlvryStateCode = pOrder.sDlvryStateCode.Substring(0, 2).ToUpper();
            }
            else
            {
                //if (DlvryCountry != "US")
                //{
                //    sDlvryStateCode = "ZZ";
                //}
                int Adrr4lng = 0, Adrr3lng = 0;
                if (!string.IsNullOrEmpty(Convert.ToString(pOrder.sDlvryAdress4)))
                {
                    Adrr4lng = pOrder.sDlvryAdress4.Length;
                }
                if (!string.IsNullOrEmpty(Convert.ToString(pOrder.sDlvryAdress3)))
                    Adrr3lng = pOrder.sDlvryAdress3.Length;

                if (Adrr3lng >= Adrr4lng)
                    sDlvryStateCode = pOrder.sDlvryAdress4;
                else
                    sDlvryStateCode = pOrder.sDlvryAdress3;
             
                if (DlvryCountry != "US")
                {
                    sDlvryStateCode = "ZZ";
                }
            }

            String Packingslip = "";

            if (DlvryCountry == "US")
            {
                Packingslip = "01130892";
            }
            else if (DlvryCountry == "AU")
            {
                Packingslip = "01130893";
            }
            else if (DlvryCountry == "CA")
            {
                Packingslip = "01130892";
            }
            else
            {
                Packingslip = "01130893";
            }
            //start of  Envelope Header
            // ISA*00*          *00*          *ZZ*01130893       *ZZ*7608772        *130822*0950*U*00401*348940000*1*T*>~
            strBuilder.Append("ISA");
            strBuilder.Append("*");
            strBuilder.Append("00");
            strBuilder.Append("*");
            strBuilder.Append("          ");
            strBuilder.Append("*");
            strBuilder.Append("00");
            strBuilder.Append("*");
            strBuilder.Append("          ");
            strBuilder.Append("*");
            strBuilder.Append("ZZ");
            strBuilder.Append("*");
            //strBuilder.Append("01130893");
            strBuilder.Append(Packingslip);          
            strBuilder.Append("       ");
            strBuilder.Append("*");
            strBuilder.Append("ZZ");
            strBuilder.Append("*");
            strBuilder.Append("7608772");
            strBuilder.Append("        ");
            strBuilder.Append("*");
            string orderdate = pOrder.dtOrderDate.ToString("yy'/'MM'/'dd");
            strBuilder.Append(orderdate.Replace("/", ""));
            strBuilder.Append("*");
            string ordertime = pOrder.dtOrderDate.ToString("hh:mm");
            strBuilder.Append(ordertime.Replace(":", ""));
            strBuilder.Append("*");
            strBuilder.Append("U");
            strBuilder.Append("*");
            strBuilder.Append("00401");
            strBuilder.Append("*");
            string Orderid = Convert.ToString(pOrder.lPOrderId);
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1;i++ )                
                {
                    strBuilder.Append("0");
                }

            }          
            strBuilder.Append("*");
            strBuilder.Append("1");
            strBuilder.Append("*");
            strBuilder.Append("T");
            strBuilder.Append("*");
            strBuilder.Append(">");
            strBuilder.Append("~");
            strBuilder.Append("\r\n");

            //GS*PO*01130893*7608772*20130822*0950*348940001*X*004010~
            strBuilder.Append("GS");
            strBuilder.Append("*");
            strBuilder.Append("PO");
            strBuilder.Append("*");
           // strBuilder.Append("01130893");
            strBuilder.Append(Packingslip);          
            strBuilder.Append("*");
            strBuilder.Append("7608772");
            strBuilder.Append("*");
            string orderdate1 = pOrder.dtOrderDate.ToString("yyyy'/'MM'/'dd");
            strBuilder.Append(orderdate1.Replace("/", ""));
            strBuilder.Append("*");
            string ordertime1 = pOrder.dtOrderDate.ToString("hh:mm");
            strBuilder.Append(ordertime1.Replace(":", ""));
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1-1; i++)
                {
                    strBuilder.Append("0");
                }
                strBuilder.Append("1");
            }          
            strBuilder.Append("*");
            strBuilder.Append("X");
            strBuilder.Append("*");
            strBuilder.Append("004010");
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            //ST*850*348940002~
            strBuilder.Append("ST");
            strBuilder.Append("*");
            strBuilder.Append("850");
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1 - 1; i++)
                {
                    strBuilder.Append("0");
                }
                strBuilder.Append("2");
            }  
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            //the order info
            //BEG*00*DS*34894**20130822~
            strBuilder.Append("BEG");
            strBuilder.Append("*");
            strBuilder.Append("00");
            strBuilder.Append("*");
            strBuilder.Append("DS");
            strBuilder.Append("*");
            strBuilder.Append(pOrder.lPOrderId);
            strBuilder.Append("**");
            string orderdate2 = pOrder.dtOrderDate.ToString("yyyy'/'MM'/'dd");
            strBuilder.Append(orderdate2.Replace("/", ""));
            strBuilder.Append("~");
            strBuilder.Append("\r\n");

            //// carrier details
            //// TD5***ULS~
            //strBuilder.Append("TD5");
            //strBuilder.Append("*");
            //strBuilder.Append("*");
            //strBuilder.Append("*");
            //strBuilder.Append("ULS");
            //strBuilder.Append("~");
            //strBuilder.Append("\r\n");
         
            //Address
          // N1*ST*Jamie Thomas~
          // N3*335 Bourke Street Mall~
          // N4*Melbourne*Vic*3000*AU~

            strBuilder.Append("N1");
            strBuilder.Append("*");
            strBuilder.Append("ST");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryName) ? pOrder.sDlvryName : "");
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            strBuilder.Append("N3");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryAdress1) ? pOrder.sDlvryAdress1.Replace("/", "-").TrimEnd() : "");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryAdress2) ? pOrder.sDlvryAdress2.Replace("/", "-").TrimEnd() : "");                      
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            strBuilder.Append("N4");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryAdress3) ? pOrder.sDlvryAdress3.TrimEnd() : "");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryAdress4) ? pOrder.sDlvryAdress4.TrimEnd() : "");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryPostalCode) ? pOrder.sDlvryPostalCode : "");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(DlvryCountry) ? DlvryCountry : "");
            strBuilder.Append("~");
            strBuilder.Append("\r\n");

            // ISBN No
            pOrder.ordSuppliervcSource = "BT";
            int count = 0, totalqty = 0;
            foreach (Order.POBooks pBook in pOrder.pOBooksOrder)
            {
                if (pBook.vcSource.ToString().ToUpper() == "BT")
                {
                    string sAmount = string.Empty;
                    sAmount = string.Format("{0:0.00}", Math.Round(pBook.decTotalPrice, 4));
                    startLine += 1;
                    strBuilder.Append("PO1");
                    strBuilder.Append("*");
                    strBuilder.Append(startLine.ToString("d2"));
                    strBuilder.Append("*");
                    strBuilder.Append(pBook.iBookQty.ToString());
                    strBuilder.Append("*");
                    strBuilder.Append("EA");
                    strBuilder.Append("*");
                    strBuilder.Append(sAmount.Trim());
                    strBuilder.Append("*");
                    strBuilder.Append("PE");
                    strBuilder.Append("*");
                    strBuilder.Append("IB");
                    strBuilder.Append("*");
                    strBuilder.Append(pBook.sIsbn);
                    strBuilder.Append("~");
                    strBuilder.Append("\r\n");
                    count++;
                    totalqty = totalqty + pBook.iBookQty;
                }

            }
            strBuilder.Append("CTT");
            strBuilder.Append("*");
            strBuilder.Append(count);
            strBuilder.Append("*");
            strBuilder.Append(totalqty);
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            strBuilder.Append("SE");
            strBuilder.Append("*");
          //  strBuilder.Append("8");
            int segment = 7 + count;
            strBuilder.Append(segment);
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1 - 1; i++)
                {
                    strBuilder.Append("0");
                }
                strBuilder.Append("2");
            }  
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            strBuilder.Append("GE");
            strBuilder.Append("*");
            strBuilder.Append(count);
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1 - 1; i++)
                {
                    strBuilder.Append("0");
                }
                strBuilder.Append("1");
            }    
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            //         IEA*1*000000118~
            strBuilder.Append("IEA");
            strBuilder.Append("*");
            strBuilder.Append(count);
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1 ; i++)
                {
                    strBuilder.Append("0");
                }
           
            }    
            strBuilder.Append("~");



            SaveOrderBakerFile(strBuilder.ToString(), pOrder.lPOrderId.ToString(), ".DONE");
            txtEdi.Text = "";
            string strPath = HttpContext.Current.Server.MapPath(Resources.Paths.BTOrderFilePath + pOrder.lPOrderId.ToString() + ".DONE");
            strPath = strPath.ToLower();
            strPath = strPath.Replace("\\admin", "");
            strPath = strPath.Replace("done", "DONE");
            strPath = strPath.Replace("ord", "ORD");          
            //redirect to your physical location
            FileStream fs = new FileStream(strPath, FileMode.Open);
            byte[] bytes = new byte[(int)fs.Length];
            fs.Read(bytes, 0, bytes.Length);
            fs.Close();
            //HttpResponse Response = HttpContext.Current.Response;
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(strPath.Split('\\')[strPath.Split('\\').Length - 1], System.Text.Encoding.UTF8));
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
       
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    #region Save Baker File in BTOrder file
    public  void SaveOrderBakerFile(string pOrder, string pFileName, string FileSource)
    {
        try
        {
            string strPath = HttpContext.Current.Server.MapPath(Resources.Paths.BTOrderFilePath + pFileName + FileSource);
            strPath = strPath.ToLower();
            strPath = strPath.Replace("\\admin", "");
            strPath = strPath.Replace("done", "DONE");
            strPath = strPath.Replace("ord", "ORD");
            using (System.IO.StreamWriter SW = new System.IO.StreamWriter(strPath))
            {
                SW.WriteLine(pOrder);
                SW.Close();
             
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    #endregion
}

java-script check for number validation

  <script language="javascript" type="text/javascript">


        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode      
            if (charCode > 31 && (charCode < 48 || charCode > 57) )
                return false;

            return true;
        }

Friday, September 27, 2013

Jquery to check password stength

--------------------jQuery Kentico----------------
 // Register jQuery and registration of script which shows password strength       
            ScriptHelper.RegisterJQuery(Page);
            ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/membership.js");

            sb.Append(";", GetString("passwordstrength.acceptable"), ";", GetString("passwordstrength.average"), ";", GetString("passwordstrength.strong"), ";", GetString("passwordstrength.excellent"));

            string regex = "''";
            if (!string.IsNullOrEmpty(RegularExpression))
            {
                regex = "/" + RegularExpression + "/";
            }

            // Javascript for calling js function on keyup of textbox
            string txtVar = "txtSearch_" + txtPassword.ClientID;
            string script =
                txtVar + " = $j('#" + txtPassword.ClientID + @"');
        if (" + txtVar + @" ) {                   
           " + txtVar + @".keyup(function(event){
                ShowStrength('" + txtPassword.ClientID + "', '" + MinLength + "', '" + PreferedLength + "', '" + MinNonAlphaNumChars + "', '"
                + PreferedNonAlphaNumChars + "', " + regex + ", '" + lblEvaluation.ClientID + "', '" + sb.ToString() + "', '" + ClassPrefix + "', '" + UsePasswordPolicy + "', '" + pnlPasswIndicator.ClientID + "', '" + UseStylesForStrenghtIndicator + @"');                              
            });                  
        }";

            ScriptHelper.RegisterStartupScript(this, typeof(string), "PasswordStrength_" + txtPassword.ClientID, ScriptHelper.GetScript(script));

Friday, September 6, 2013

Implementing EDI format to sent order info in ASP.NET

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Text;
using System.Configuration;
using System.IO;
using System.Net;
using System.Net.Mail;
using ThisSite.Common;
using System.Web.Routing;
using ThisSite.BSLayer;


public partial class Admin_GenerateEdi : AdminPageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnGenrateEdi_Click(object sender, EventArgs e)
    {
        Int64 lOrderId = Convert.ToInt64(txtEdi.Text.Trim());
        int BTcount = 0;
        Order pOrder = new Order(lOrderId);
        for (int i = 0; i < pOrder.pOBooks.Count; i++)
        {

            if ((pOrder.pOBooks[i].vcSource.ToString().ToUpper() == "BT") && BTcount == 0)
            {
                GnrtOrdForBakerEDI(pOrder);              
                BTcount = BTcount + 1;
            }
        }      
    }

    public  void GnrtOrdForBakerEDI(Order pOrder)
    {
        try
        {
            StringBuilder strBuilder = new StringBuilder();
            int startLine = 0;      
            string DlvryCountry = string.Empty;
            if (pOrder.lDlvryCoutry.HasValue)
            {
                Country pCountry = new Country(Convert.ToInt64(pOrder.lDlvryCoutry.Value));              
                DlvryCountry = pCountry.sISOAlpha2;
            }
            if (pOrder.lDlvryCoutry.HasValue)
            {
                Country pCountry = new Country(Convert.ToInt64(pOrder.lDlvryCoutry.Value));
                //DlvryCountry = pCountry.sCountryNm.Substring(0, 2).ToUpper(); ;
                DlvryCountry = pCountry.sISOAlpha2;
            }
            if (pOrder.lDlvryCoutry.HasValue)
            {
                Country pCountry = new Country(Convert.ToInt64(pOrder.lDlvryCoutry.Value));
                //DlvryCountry = pCountry.sCountryNm.Substring(0, 2).ToUpper(); ;
                DlvryCountry = pCountry.sISOAlpha2;
            }
            string sDlvryStateCode = string.Empty;
            if (!string.IsNullOrEmpty(pOrder.sDlvryStateCode))
            {
                sDlvryStateCode = pOrder.sDlvryStateCode.Substring(0, 2).ToUpper();
            }
            else
            {
                //if (DlvryCountry != "US")
                //{
                //    sDlvryStateCode = "ZZ";
                //}
                int Adrr4lng = 0, Adrr3lng = 0;
                if (!string.IsNullOrEmpty(Convert.ToString(pOrder.sDlvryAdress4)))
                {
                    Adrr4lng = pOrder.sDlvryAdress4.Length;
                }
                if (!string.IsNullOrEmpty(Convert.ToString(pOrder.sDlvryAdress3)))
                    Adrr3lng = pOrder.sDlvryAdress3.Length;

                if (Adrr3lng >= Adrr4lng)
                    sDlvryStateCode = pOrder.sDlvryAdress4;
                else
                    sDlvryStateCode = pOrder.sDlvryAdress3;
             
                if (DlvryCountry != "US")
                {
                    sDlvryStateCode = "ZZ";
                }
            }

            String Packingslip = "";

            if (DlvryCountry == "US")
            {
                Packingslip = "01130892";
            }
            else if (DlvryCountry == "AU")
            {
                Packingslip = "01130893";
            }
            else if (DlvryCountry == "CA")
            {
                Packingslip = "01130892";
            }
            else
            {
                Packingslip = "01130893";
            }
            //start of  Envelope Header
            // ISA*00*          *00*          *ZZ*01130893       *ZZ*7608772        *130822*0950*U*00401*348940000*1*T*>~
            strBuilder.Append("ISA");
            strBuilder.Append("*");
            strBuilder.Append("00");
            strBuilder.Append("*");
            strBuilder.Append("          ");
            strBuilder.Append("*");
            strBuilder.Append("00");
            strBuilder.Append("*");
            strBuilder.Append("          ");
            strBuilder.Append("*");
            strBuilder.Append("ZZ");
            strBuilder.Append("*");
            //strBuilder.Append("01130893");
            strBuilder.Append(Packingslip);          
            strBuilder.Append("       ");
            strBuilder.Append("*");
            strBuilder.Append("ZZ");
            strBuilder.Append("*");
            strBuilder.Append("7608772");
            strBuilder.Append("        ");
            strBuilder.Append("*");
            string orderdate = pOrder.dtOrderDate.ToString("yy'/'MM'/'dd");
            strBuilder.Append(orderdate.Replace("/", ""));
            strBuilder.Append("*");
            string ordertime = pOrder.dtOrderDate.ToString("hh:mm");
            strBuilder.Append(ordertime.Replace(":", ""));
            strBuilder.Append("*");
            strBuilder.Append("U");
            strBuilder.Append("*");
            strBuilder.Append("00401");
            strBuilder.Append("*");
            string Orderid = Convert.ToString(pOrder.lPOrderId);
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1;i++ )                
                {
                    strBuilder.Append("0");
                }

            }            
            strBuilder.Append("*");
            strBuilder.Append("1");
            strBuilder.Append("*");
            strBuilder.Append("T");
            strBuilder.Append("*");
            strBuilder.Append(">");
            strBuilder.Append("~");
            strBuilder.Append("\r\n");

            //GS*PO*01130893*7608772*20130822*0950*348940001*X*004010~
            strBuilder.Append("GS");
            strBuilder.Append("*");
            strBuilder.Append("PO");
            strBuilder.Append("*");
           // strBuilder.Append("01130893");
            strBuilder.Append(Packingslip);          
            strBuilder.Append("*");
            strBuilder.Append("7608772");
            strBuilder.Append("*");
            string orderdate1 = pOrder.dtOrderDate.ToString("yyyy'/'MM'/'dd");
            strBuilder.Append(orderdate1.Replace("/", ""));
            strBuilder.Append("*");
            string ordertime1 = pOrder.dtOrderDate.ToString("hh:mm");
            strBuilder.Append(ordertime1.Replace(":", ""));
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1-1; i++)
                {
                    strBuilder.Append("0");
                }
                strBuilder.Append("1");
            }            
            strBuilder.Append("*");
            strBuilder.Append("X");
            strBuilder.Append("*");
            strBuilder.Append("004010");
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            //ST*850*348940002~
            strBuilder.Append("ST");
            strBuilder.Append("*");
            strBuilder.Append("850");
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1 - 1; i++)
                {
                    strBuilder.Append("0");
                }
                strBuilder.Append("2");
            }  
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            //the order info
            //BEG*00*DS*34894**20130822~
            strBuilder.Append("BEG");
            strBuilder.Append("*");
            strBuilder.Append("00");
            strBuilder.Append("*");
            strBuilder.Append("DS");
            strBuilder.Append("*");
            strBuilder.Append(pOrder.lPOrderId);
            strBuilder.Append("**");
            string orderdate2 = pOrder.dtOrderDate.ToString("yyyy'/'MM'/'dd");
            strBuilder.Append(orderdate2.Replace("/", ""));
            strBuilder.Append("~");
            strBuilder.Append("\r\n");

            //// carrier details
            //// TD5***ULS~
            //strBuilder.Append("TD5");
            //strBuilder.Append("*");
            //strBuilder.Append("*");
            //strBuilder.Append("*");
            //strBuilder.Append("ULS");
            //strBuilder.Append("~");
            //strBuilder.Append("\r\n");
         
            //Address
          // N1*ST*Jamie Thomas~
          // N3*335 Bourke Street Mall~
          // N4*Melbourne*Vic*3000*AU~

            strBuilder.Append("N1");
            strBuilder.Append("*");
            strBuilder.Append("ST");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryName) ? pOrder.sDlvryName : "");
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            strBuilder.Append("N3");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryAdress1) ? pOrder.sDlvryAdress1.Replace("/", "-").TrimEnd() : "");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryAdress2) ? pOrder.sDlvryAdress2.Replace("/", "-").TrimEnd() : "");                      
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            strBuilder.Append("N4");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryAdress3) ? pOrder.sDlvryAdress3.TrimEnd() : "");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryAdress4) ? pOrder.sDlvryAdress4.TrimEnd() : "");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(pOrder.sDlvryPostalCode) ? pOrder.sDlvryPostalCode : "");
            strBuilder.Append("*");
            strBuilder.Append(!string.IsNullOrEmpty(DlvryCountry) ? DlvryCountry : "");
            strBuilder.Append("~");
            strBuilder.Append("\r\n");

            // ISBN No
            pOrder.ordSuppliervcSource = "BT";
            int count = 0, totalqty = 0;
            foreach (Order.POBooks pBook in pOrder.pOBooksOrder)
            {
                if (pBook.vcSource.ToString().ToUpper() == "BT")
                {
                    string sAmount = string.Empty;
                    sAmount = string.Format("{0:0.00}", Math.Round(pBook.decTotalPrice, 4));
                    startLine += 1;
                    strBuilder.Append("PO1");
                    strBuilder.Append("*");
                    strBuilder.Append(startLine.ToString("d2"));
                    strBuilder.Append("*");
                    strBuilder.Append(pBook.iBookQty.ToString());
                    strBuilder.Append("*");
                    strBuilder.Append("EA");
                    strBuilder.Append("*");
                    strBuilder.Append(sAmount.Trim());
                    strBuilder.Append("*");
                    strBuilder.Append("PE");
                    strBuilder.Append("*");
                    strBuilder.Append("IB");
                    strBuilder.Append("*");
                    strBuilder.Append(pBook.sIsbn);
                    strBuilder.Append("~");
                    strBuilder.Append("\r\n");
                    count++;
                    totalqty = totalqty + pBook.iBookQty;
                }

            }
            strBuilder.Append("CTT");
            strBuilder.Append("*");
            strBuilder.Append(count);
            strBuilder.Append("*");
            strBuilder.Append(totalqty);
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            strBuilder.Append("SE");
            strBuilder.Append("*");
          //  strBuilder.Append("8");
            int segment = 7 + count;
            strBuilder.Append(segment);
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1 - 1; i++)
                {
                    strBuilder.Append("0");
                }
                strBuilder.Append("2");
            }  
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            strBuilder.Append("GE");
            strBuilder.Append("*");
            strBuilder.Append(count);
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1 - 1; i++)
                {
                    strBuilder.Append("0");
                }
                strBuilder.Append("1");
            }    
            strBuilder.Append("~");
            strBuilder.Append("\r\n");
            //         IEA*1*000000118~
            strBuilder.Append("IEA");
            strBuilder.Append("*");
            strBuilder.Append(count);
            strBuilder.Append("*");
            if (Orderid.Length >= 9)
            {
                strBuilder.Append(Orderid);
            }
            else
            {
                int count1, len = 0;
                len = Orderid.Length;
                count1 = 9 - len;
                strBuilder.Append(Orderid);
                for (int i = 1; i <= count1 ; i++)
                {
                    strBuilder.Append("0");
                }
             
            }    
            strBuilder.Append("~");



            SaveOrderBakerFile(strBuilder.ToString(), pOrder.lPOrderId.ToString(), ".DONE");
            txtEdi.Text = "";
            string strPath = HttpContext.Current.Server.MapPath(Resources.Paths.BTOrderFilePath + pOrder.lPOrderId.ToString() + ".DONE");
            strPath = strPath.ToLower();
            strPath = strPath.Replace("\\admin", "");
            strPath = strPath.Replace("done", "DONE");
            strPath = strPath.Replace("ord", "ORD");          
            //redirect to your physical location
            FileStream fs = new FileStream(strPath, FileMode.Open);
            byte[] bytes = new byte[(int)fs.Length];
            fs.Read(bytes, 0, bytes.Length);
            fs.Close();
            //HttpResponse Response = HttpContext.Current.Response;
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(strPath.Split('\\')[strPath.Split('\\').Length - 1], System.Text.Encoding.UTF8));
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
         
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    #region Save Baker File in BTOrder file
    public  void SaveOrderBakerFile(string pOrder, string pFileName, string FileSource)
    {
        try
        {
            string strPath = HttpContext.Current.Server.MapPath(Resources.Paths.BTOrderFilePath + pFileName + FileSource);
            strPath = strPath.ToLower();
            strPath = strPath.Replace("\\admin", "");
            strPath = strPath.Replace("done", "DONE");
            strPath = strPath.Replace("ord", "ORD");
            using (System.IO.StreamWriter SW = new System.IO.StreamWriter(strPath))
            {
                SW.WriteLine(pOrder);
                SW.Close();
               
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    #endregion
}

Tuesday, September 3, 2013

Implementing PayPal on ASP.net website

JUST  FOLLOW THESE THREE STEPS :
set : assign all credential , qty price
get  :get token id , paypalid

do capture :with the hep of paypalid do final payment

Step 1:  In Checkout Page :call PayPal method

   protected void lnkPaypal_Click(object sender, EventArgs e)
    {
            //PaymentThrougPaypal();
            try
            {
                //UpdatePackageOrder();
                PaymentThrougPaypal();
            }
            catch (Exception ex)
            {
                ErrorLog error = new ErrorLog();
                error.lUsrId = Test.BusinessLayer.BusinessAccessLayer.User.Current.lUsrId;
                error.sClientIP = Request.UserHostAddress;
                error.sAbsoluteUri = Request.Url.AbsoluteUri;
                error.sErrMsg = ex.Message;
                error.sStackTrace = ex.Message;
                error.Create();
                //if (ex.Message != "Thread was being aborted.")
                //RollBackUpdatePackageOrder();
            }
    }
    #region Paypal integration
    private void PaymentThrougPaypal()
    {
      //  Session["payment_amt"] = 1000;
        //NVPAPICaller test = new NVPAPICaller();
        string retMsg = "";
        string token = "";
        string sLogo = "http://www.test.com/App_Themes/Default/images/logo1.jpg";
        Test.Paypal.PaypalIntegration.PaypalIntegration paypalRequest = new Test.Paypal.PaypalIntegration.PaypalIntegration();
        paypalRequest.OrderID = OrderId;
        //paypalRequest.ReqConfirmShipping = "1";
        paypalRequest.logo = sLogo;

        Order pOrder = new Order(OrderId);
            if (pOrder.decNetAmount != null)
            {
               // Math.Round((decimal)order.decNetAmount, 2).ToString();
               string host = "www.paypal.com";//"www.paypal.com";//
               // string host = "www.sandbox.paypal.com";
                //string amt = pOrder.decNetAmount.ToString();
               decimal amt1 =Convert.ToDecimal(pOrder.decNetAmount);
               string amt = Math.Round((decimal)amt1, 2).ToString();
              // string amt = Math.Round((decimal)amt1, 2).ToString() + ((pOrder.decPackagePrice.HasValue) ? pOrder.decPackagePrice.Value : 0);
                Test.Paypal.Paypal.Paypal eSet = new Test.Paypal.Paypal.Paypal();
                Test.Paypal.PaypalIntegration.PaypalIntegration _paypalRequest = new Test.Paypal.PaypalIntegration.PaypalIntegration();
               token = eSet.ECSetExpressCheckoutCode(amt, "http://www.test.com/paydetails.aspx", "http://www.test.com/Checkout.aspx", com.paypal.soap.api.PaymentActionCodeType.Order, com.paypal.soap.api.CurrencyCodeType.AUD, paypalRequest, Convert.ToInt64(pOrder.lPOrderId));
 Response.Redirect("https://" + host + "/cgi-bin/webscr?cmd=_express-checkout" + "&token=" + token);
            }
       
    }
    #endregion


Step 2: In Separate Page do all coding to make transactions, this page will run in background
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.paypal.sdk.services;
using com.paypal.soap.api;
using com.paypal.sdk.profiles;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Web.Routing;
using GenerateCodeSOAP;
using System.IO;
using System.Collections;
using System.Net;
using System.Net.Mail;
using System.Xml;
using Test.Common;
using Test.Paypal.Paypal;
using Test.BusinessLayer.BusinessAccessLayer;
using Test.BusinessLayer.DataAccessLayer;


public partial class paydetails : FrontPageBase
{
    string token = "";
    string payerId = "";
    string amt = "";
    string InvoiceId = "";
    string cardHolderNm = "";
    string bilAdd = "";
    string traId = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["token"] != null)
        {
            GetExpressCheckoutDetailsResponseType resp = new GetExpressCheckoutDetailsResponseType();
            Test.Paypal.ECGetExpressCheckout ecGet = new Test.Paypal.ECGetExpressCheckout();
            resp = ecGet.ECGetExpressCheckoutCode(Request.QueryString["token"].ToString());
            //Response.Write(resp);
            payerId = resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID.ToString();
            amt = resp.GetExpressCheckoutDetailsResponseDetails.PaymentDetails.OrderTotal.Value;
            token = resp.GetExpressCheckoutDetailsResponseDetails.Token.ToString();
            InvoiceId = resp.GetExpressCheckoutDetailsResponseDetails.InvoiceID.ToString();
            cardHolderNm = (!string.IsNullOrEmpty(resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerName.FirstName) ? resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerName.FirstName : string.Empty)
                + "  " + (!string.IsNullOrEmpty(resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerName.LastName) ? resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerName.LastName : string.Empty);
            bilAdd = (!string.IsNullOrEmpty(resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.CityName.ToString()) ? resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.CityName.ToString() : string.Empty)
            + "<br/>" + (!string.IsNullOrEmpty(resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Street1.ToString()) ? resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Street1.ToString() : string.Empty)
            + "<br/>" + (!string.IsNullOrEmpty(resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Street2.ToString()) ? resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Street2.ToString() : string.Empty)
            + "<br/>" + (!string.IsNullOrEmpty(resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.CountryName.ToString()) ? resp.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.CountryName.ToString() : string.Empty);

        }

        if (token != "" && payerId != "")
        {
            DoExpressCheckoutPaymentResponseType ecDoPayment = new DoExpressCheckoutPaymentResponseType();
            Test.Paypal.ECDoExpressCheckout doPayment = new Test.Paypal.ECDoExpressCheckout();
            ecDoPayment = doPayment.ECDoExpressCheckoutCode(token, payerId, amt, com.paypal.soap.api.PaymentActionCodeType.Order, com.paypal.soap.api.CurrencyCodeType.AUD);
            string ack = ecDoPayment.Ack.ToString();
            string authorizationId = ecDoPayment.DoExpressCheckoutPaymentResponseDetails.PaymentInfo.TransactionID;
            string amtValue = ecDoPayment.DoExpressCheckoutPaymentResponseDetails.PaymentInfo.GrossAmount.Value;

            com.paypal.soap.api.CurrencyCodeType amtCurrencyCodeType = com.paypal.soap.api.CurrencyCodeType.AUD;
            Test.Paypal.DoCapture doCapt = new Test.Paypal.DoCapture();
            //Response.Write(ack);
            DoCaptureResponseType doCaptrDetails = new DoCaptureResponseType();
            //  doCaptrDetails = doCapt.DoCaptureCode(authorizationId, note, amtValue, amtCurrencyCodeType, InvoiceId);
            doCaptrDetails = doCapt.DoCaptureCode(authorizationId, amtValue, amtCurrencyCodeType, InvoiceId);
            string captrAck = doCaptrDetails.Ack.ToString();
            //Response.Write(captrAck);
            // Response.Write(ack + "//" + InvoiceId + "//" + captrAck);
            // Response.End();
            if ((ack.ToLower() == "success") && (!String.IsNullOrEmpty(InvoiceId)) && (captrAck.ToLower() == "success"))
            {
                try
                {

                    Order pOrder = new Order(Convert.ToInt64(InvoiceId));
                    Outlet outlet = new Outlet(pOrder.lOutletId);
                    pOrder.orderStatus = Order.OrderStatus.Placed;
                    pOrder.pymtStatus = Order.PaymentStatus.Made;
                    pOrder.sTransactionId = doCaptrDetails.DoCaptureResponseDetails.PaymentInfo.TransactionID.ToString();
                    Response.Write(pOrder.sTransactionId);
                    traId = doCaptrDetails.DoCaptureResponseDetails.PaymentInfo.TransactionID.ToString();
                    pOrder.sPaymentType = "Paypal";
                    pOrder.sGatewaynm = "Paypal";
                    string paypal="paypal";
                    Invoice.GenerateInvoice_New(pOrder,paypal);
                    Invoice.GenerateInvoice_Customer(pOrder,paypal);
                    pOrder.Update();

                    #region Email to Customer with invoice attachment

                    DataTable dtOutletChainColContTemplVal;
                    CMS cms;
                    ContentTemplate conTemp;

                    dtOutletChainColContTemplVal = Test.BusinessLayer.DataAccessLayer.DBChain.PopulateOutletChainsColumnValue(outlet.lOutletId, "TaxInvEmlCustId");

                    if (dtOutletChainColContTemplVal != null)
                    {
                        conTemp = new ContentTemplate(Int16.Parse(dtOutletChainColContTemplVal.Rows[0][0].ToString()));
                        cms = new CMS(Test.BusinessLayer.BusinessAccessLayer.Site.Current.lSiteId, conTemp.shContentTempId);
                    }
                    else
                    {
                        conTemp = new ContentTemplate(Resources.ContentName.mailorderandtaxinvoice);
                        cms = new CMS(Test.BusinessLayer.BusinessAccessLayer.Site.Current.lSiteId, conTemp.shContentTempId);
                    }

  InsertPapalInfo();

Response.Redirect("http://test.com/thank-you-for-your-order.aspx");
}

catch (Exception ex)
                {
                   
                    Response.Write("catch");
                    throw;

                }

            }
            else
            {
                Response.Redirect("http://test.com/Checkout.aspx");
            }

else
        {
            Response.Redirect("http://test.com/Checkout.aspx");
        }



#region method to update Paypal user info
    public void InsertPapalInfo()
    {

        test.BusinessLayer.DataAccessLayer.DBPaypalInfo.InsertPaypalInfo(Convert.ToInt64(InvoiceId), cardHolderNm, bilAdd, traId);

    }
    #endregion

Step 3 :Configure all .cs files

a)      DoCapture.cs
b)      ECDoExpressCheckout.cs
c)       ECGetExpressCheckout.cs
d)      ECSetExpressCheckout.cs
e)      Paypal.cs
f)       PaypalIntegration.cs
And Payflow_dotNET.dll to bin now paypal will work for you thanks !!!!