Thursday, June 28, 2012

using CCAVENUE IN asp.net


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   
</head>
<body>
 <script src="http://cdn.webrupee.com/js" type="text/javascript"></script>
<form id="xx" runat="server" >
<div style="background:url(images/bg.jpg) repeat-x #FFFFFF left top; height:200px; width:100%; "  >
<div align="center" style="padding-top:25px;"><img src="images/ccave-logo.png" alt="alt" /></div>

<div style="margin-top:93px; font-size:12px; font-family:Arial, Helvetica, sans-serif; color:#0099FF;" align="center">

    <asp:ImageButton ID="ImageButton1" runat="server" 
        ImageUrl="~/images/cancel.jpg" onclick="ImageButton1_Click" />
</div>
</div>
<div style="margin-top:93px; font-size:12px; font-family:Arial, Helvetica, sans-serif; color:#0099FF;" align="center">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    CellPadding="2" CellSpacing="2" CssClass="Normal" BorderColor="#003300" 
    Font-Bold="True" ForeColor="#FF0066" >
                    <Columns>                                 
                             
                        <asp:TemplateField HeaderText="Order ID" Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="lblOrderID" runat="server" Visible="False" Text='<%# Bind("ShoppingCartRecID") %>'
                                    CssClass="Normal"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>                        
                        <asp:TemplateField HeaderText="CustomerID" SortExpression="CustomerID">
                            <ItemStyle />
                            <ItemTemplate>
                <asp:Label ID="lblCustomerID" runat="server" Text='<%# Bind("CustomerID") %>' CssClass="Normal"></asp:Label>
           </ItemTemplate>
                           </asp:TemplateField>                        
                        <asp:TemplateField HeaderText="Customer Name" SortExpression="Customer Name">
                            <ItemStyle />
                            <ItemTemplate>
                <asp:Label ID="lblEmployeeID" runat="server" Text='<%# Bind("Cust_Name") %>' CssClass="Normal"></asp:Label>
                </ItemTemplate>
                          </asp:TemplateField>                        
                        <asp:TemplateField HeaderText="Email" SortExpression="Email">
                            <ItemStyle />
                            <ItemTemplate>  
                <asp:Label ID="lblOrderDate" runat="server" Text='<%# Bind("Email") %>' CssClass="Normal"></asp:Label>                 
                </ItemTemplate>
                          
                        </asp:TemplateField>                        
                        <asp:TemplateField HeaderText="Product Name" SortExpression="Product Name">
                            <ItemStyle />
                            <ItemTemplate>  
                <asp:Label ID="lblRequiredDate" runat="server" Text='<%# Bind("Name") %>' CssClass="Normal"></asp:Label>                 
                </ItemTemplate>
                          
                        </asp:TemplateField>                        
                        <asp:TemplateField HeaderText="Quantity" SortExpression="Quantity">
                            <ItemStyle />
                            <ItemTemplate>  
                <asp:Label ID="lblShippedDate" runat="server" Text='<%# Bind("Quantity") %>' CssClass="Normal"></asp:Label>                 
                </ItemTemplate>
                          
                        </asp:TemplateField>                        
                        <asp:TemplateField HeaderImageUrl="images/symbol21.jpg" SortExpression="Price" >
                            <ItemStyle />
                            <ItemTemplate>
                <asp:Label ID="lblShipVia" runat="server" Text='<%# Bind("totalprice") %>' CssClass="Normal"></asp:Label>
                </ItemTemplate>
                         
                        </asp:TemplateField>                        
                          
                    </Columns>
                    <HeaderStyle ForeColor="#003300" />
                    <PagerStyle HorizontalAlign="Left"/>
                    <SelectedRowStyle ForeColor="#660033" />
                </asp:GridView>

</div>
<div>
   </div>
</form>
<br /><br />
<div align="center">
    <form action="https://www.ccavenue.com/sdsdsd/cc_details.jsp" method="post">
    
   <div>
 

        <input type="hidden" name="Order_Id" id="Order_Id"  value="Order_Id" runat="server"/>
            <input  type="hidden" name="Amount" id="Amount" value="AMOUNT" runat="server"/>
            <input type="hidden"name="Merchant_Id" id="Merchant_Id" value=" add your  Merchant ID"/>
            <input id="Hidden1" type="hidden" name="Redirect_Url" value="redirect url" runat="server" />
            <input type="hidden" name="billing_cust_name" id="billing_cust_name" value="" runat="server"/> 
            <input type="hidden" name="billing_cust_address" id="billing_cust_address" value="" runat="server"/> 
            <input type="hidden" name="billing_cust_country" id="billing_cust_country" value="" runat="server"/> 
            <input type="hidden" name="billing_cust_tel" id="billing_cust_tel" value="" runat="server"/> 
            <input type="hidden" name="billing_cust_email" id="billing_cust_email" value="" runat="server"/> 
            <input type="hidden" name="billing_zip_code" id="billing_zip_code"  value="" runat="server"/> 
            <input type="hidden" name="billing_cust_state" id="billing_cust_state" value="" runat="server"/> 
            <input type="hidden" name="billing_cust_city" id="billing_cust_city" value="" runat="server"/> 
            <input type="hidden" name="billing_cust_notes" id="billing_cust_notes" value="" runat="server"/> 
            <input type="hidden" name="delivery_cust_name" id="delivery_cust_name" value="" runat="server"/> 
            <input type="hidden" name="delivery_cust_address" id="delivery_cust_address" value="" runat="server"/> 
            <input type="hidden" name="delivery_cust_tel" id="delivery_cust_tel" value="" runat="server"/> 
            <input type="hidden" name="delivery_zip_code" id="delivery_zip_code" value="" runat="server"/> 
            <input type="hidden" name="delivery_cust_state" id="delivery_cust_state" value="" runat="server"/> 
            <input type="hidden" name="delivery_cust_city" id="delivery_cust_city" value="" runat="server"  /> 
            <input  type="image" src="images/submit.jpg" >
    </div>
    
    </form>
    </div>
    
</body>
</html>



In the Coding Part  i  have to set the Values 

so i have set the values like that


 string   NetPrice = Convert.ToString (Session["ashish"]);
        string custid = Convert.ToString(Session["name"]);
       SqlConnection con = new SqlConnection();
       con.ConnectionString = ConfigurationManager.AppSettings["DBConn"];
       con.Open();
       SqlCommand cmd = new SqlCommand();
       cmd.CommandText = "insert into tbtemp values(" + NetPrice + "," + custid + ")";
       cmd.Connection = con;
       cmd.ExecuteNonQuery();
       cmd.Dispose();
        SqlDataAdapter adp = new SqlDataAdapter("dbo.ashish", con);
        adp.SelectCommand.CommandType = CommandType.StoredProcedure;
        adp.SelectCommand.Parameters.Add("@CustomerID", SqlDbType.Int).Value = Session["name"];

        DataSet ds = new DataSet();

        adp.Fill(ds);
              GridView1.DataSource = ds;
        GridView1.DataBind();






        string Merchant_Id, Amountamt, Order, Redirect_Url, WorkingKey, intChecksum;
        Merchant_Id = "Merchant id given by CCAvenue";
        Order = ds.Tables[0].Rows[0]["ShoppingCartRecID"].ToString();
        Amountamt = NetPrice.ToString();
        Redirect_Url = "Redirect url from ccavenue to your website";
        WorkingKey = "2nye4orvbc7glrplb9";
        intChecksum = myUtility.getchecksum(Merchant_Id, Order, Amountamt, Redirect_Url, WorkingKey);


        Order_Id.Attributes["value"] = intChecksum;
        Amount.Attributes["value"] = ds.Tables[0].Rows[0]["netprice"].ToString();
        billing_cust_name.Attributes["value"] = ds.Tables[0].Rows[0]["Cust_Name"].ToString();
        billing_cust_address.Attributes["value"] = ds.Tables[0].Rows[0]["Address1"].ToString();
        billing_cust_country.Attributes["value"] = ds.Tables[0].Rows[0]["Country"].ToString();
        billing_cust_tel.Attributes["value"] = ds.Tables[0].Rows[0]["Phone"].ToString();
        billing_cust_email.Attributes["value"] = ds.Tables[0].Rows[0]["Email"].ToString();
        billing_zip_code.Attributes["value"] = ds.Tables[0].Rows[0]["Zip"].ToString();
        billing_cust_state.Attributes["value"] = ds.Tables[0].Rows[0]["State"].ToString();
        billing_cust_city.Attributes["value"] = ds.Tables[0].Rows[0]["City"].ToString();
        billing_cust_notes.Attributes["value"] = ds.Tables[0].Rows[0]["Notes"].ToString();
        delivery_cust_name.Attributes["value"] = ds.Tables[0].Rows[0]["Cust_Name"].ToString();
        delivery_cust_address.Attributes["value"] = ds.Tables[0].Rows[0]["Address2"].ToString();
        delivery_cust_tel.Attributes["value"] = ds.Tables[0].Rows[0]["Phone"].ToString();
        delivery_zip_code.Attributes["value"] = ds.Tables[0].Rows[0]["Zip"].ToString();
        delivery_cust_state.Attributes["value"] = ds.Tables[0].Rows[0]["State"].ToString();
        delivery_cust_city.Attributes["value"] = ds.Tables[0].Rows[0]["City"].ToString();

Comparision of string value in asp.net


I have some to do some comarison onthe text file  so i display the TEXT file into the textbox and second TEXT file in to the Second Textbox  and afetr that i compare both file         


string testString1 = TextBox1.Text.ToString();
        string testString2 = TextBox2.Text.ToString();
        int result = string.Compare(testString1, testString2);
        Label1.Text = result.ToString(); 

adding CSS file dynamically


call this Feature on the button event

where font size will be increased or decresed  using upon the Style sheet

System.Web.UI.HtmlControls.HtmlLink link = new System.Web.UI.HtmlControls.HtmlLink();
        link.Href = "~Styles/Site.css";
        link.Attributes.Add("rel", "stylesheet");
        link.Attributes.Add("type", "text/css");
        This.Controls.Add(link);