Monday, December 7, 2015

@{
    ViewBag.Title = "Product";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/ui-bootstrap-tpls-0.10.0.min.js"></script>
<link href="~/Scripts/bootstrap.min.css" rel="stylesheet" />
<script src="/Scripts/jquery-1.7.1.js"></script>

<script>
    var appProd = angular.module("appProd", ['ui.bootstrap']);
    appProd.filter('startFrom', function () {
        return function (input, start) {
            if (input) {
                start = +start; //parse to int
                return input.slice(start);
            }
            return [];
        }
    });
    appProd.controller("cntProduct", function ($scope, $http, $timeout, $modal, $log) {
        var catid = 0;
        $scope.list = [];
        $scope.entryLimit = 2;
        debugger;
        $.ajax({
            type: 'GET',
            contentType: 'application/json; charset=utf-8',
            url: '/Home/GetList',
            success: function (data) {
                debugger;
                window.alert(1);
                $scope.list = data;
                $scope.currentPage = 1;
                $scope.entryLimit = 2;
                $scope.filteredItems = $scope.list.length;
                $scope.totalItems = $scope.list.length;
                if (catid == '1') {
                    $scope.bClass = "selected";
                    $scope.mClass = "";
                } else {
                    $scope.bClass = "";
                    $scope.mClass = "selected";
                }
            },
            error: function (response) {
                debugger;
                window.alert(1);
            }
        });

        $scope.setPage = function (pageNo) {
            $scope.currentPage = pageNo;
        };
        $scope.filter = function () {
            debugger;
            $timeout(function () {
                $scope.filteredItems = $scope.filtered.length;
            }, 10);

        };

        $scope.getText = function (obj) {
            debugger;

            return obj.replace(' ', '-').replace('&', '-');
        };



    });
</script>
<div id="scartcontent" class="scartcontent" ng-app="appProd" ng-controller="cntProduct">
    <div class="clr pad10"></div>

    <div class="fright cart">
        <div>
            <span>
                <img src='../../images/card-img.jpg' width="31" height="28" alt="" align="absmiddle" /></span><span> hjuyjuyjuy
                 <a href="ViewBasket" title="go to shopping cart">
                     <img src='../../images/green-chkout.jpg' title="Checkout" alt="" align="absmiddle" class="margL10" />
                 </a>
                </span>
        </div>

    </div>
    <div class="cd-tabs">
        <nav>
            <ul class="cd-tabs-navigation">
                <li style="display: none;"><a class="{{bClass}}" n1111g-click="getProductList('1')">Book</a>
                </li>
                <li><a class="{{mClass}}" ng11111-click="getProductList('2')">Magazine</a>
                </li>
            </ul>
            <!-- cd-tabs-navigation -->
        </nav>
        <ul class="cd-tabs-content">
            <li class="selected">

                <div class="pad5">
                    <div class="fleft pad10">
                        PageSize:                        
                    <select ng-model="entryLimit">
                        <option>2</option>
                        <option>5</option>
                        <option>10</option>
                        <option>20</option>
                        <option>50</option>
                        <option>100</option>
                    </select>
                    </div>
                    <div class="fright pad10">
                        <input type="text" class="add_input2 pad5" ng-model="search" ng-change="filter()" id="txtSearch" placeholder="Search Book/Magazine here" />
                    </div>
                </div>
                <div class="clear"></div>
                <div class="gd-row" align="center">

                    <div class="gd-col gu3" ng-repeat="prod in filtered = (list | filter:{ProductName:search}) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">

                        <div class="product-unit">
                            <div class="center">
                                <a ng-disabled='{{prod.OutOfStock=="0"? false :true }}' ng-href="{{prod.CategoryId}}/{{prod.ProductId}}/PD/{{getText(prod.ProductName)}}">
                                    <img style="width: 103px; height: 142px" ng-src="../../Images/{{ prod.ProductImage}}" /></a>
                            </div>
                            <div class="pu-details">
                                <div class="height35">
                                    {{prod.ProductName}}-  {{prod.ProductSummary}}
                                </div>

                                <div class="pu-price margT8">
                                    <div class="pu-border-top padT5">
                                        <div class="margB5">Rs.{{prod.DisplayProductPrice}}</div>
                                    </div>
                                    <div class="pu-border-top"></div>
                                </div>
                                <div class='{{prod.OutOfStock=="0"? "avalb":"notavalb" }}'>
                                    {{prod.OutOfStock=="0"? "Available":"Out of Stock" }}
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
            </li>
        </ul>
        <div class="clear"></div>
        <div class="col-mid-10" style="background: #fff;">
            <div class="pad5">
                <div class="col-wid-10" ng-show="filteredItems == 0">
                    <h4>No Product found as per Search keyword </h4>
                </div>
            </div>
            <div class="clear"></div>
            <div class="fleft col-mid-10" ng-show="filteredItems > 0">
                <div class="fleft col-wid-3 pad10">
                    {{ "Showing " + (currentPage == 1 ? "1" : ((currentPage - 1) * entryLimit)+1) + " to " +
               ((currentPage * entryLimit) >= filteredItems ? filteredItems : (currentPage * entryLimit))
                 + " of " + filteredItems + " Items";}}
                </div>
                <div class="fright pagination-small margR10">
                    <div pagination="" page="currentPage" on-select-page="setPage(page)"
                        boundary-links="true" total-items="filteredItems" items-per-page="entryLimit"
                        previous-text="&laquo;" next-text="&raquo;">
                    </div>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="disclm">
        <strong>Disclaimer</strong>:- All Magazines listed at this site belongs to Publication Division, Ministry of Info. & Broadcasting, for any product related queries or issues customers will have to contact the ministry at 011-2436 7453, email-id pdjucir@gmail.com  for any product non-delivery / refund / quality or other issues related to the magazines listed here. Office of CGA (BharatKosh Portal Owner) will complete financial transaction related activity only.
    </div>
    <div class="clear"></div>

</div>
<div class="clr pad10"></div>
<div class="clr padB20"></div>

Simple Way To Use Pivot In SQL Query


SELECT * FROM (SELECT year(invoiceDate) as [year], left(datename(month,invoicedate),3)as [month], _
InvoiceAmount as Amount FROM Invoice) as InvoiceResult


--------------------------
SELECT *
FROM (
    SELECT
        year(invoiceDate) as [year],left(datename(month,invoicedate),3)as [month],
        InvoiceAmount as Amount
    FROM Invoice
) as s
PIVOT
(
    SUM(Amount)
    FOR [month] IN (jan, feb, mar, apr,
    may, jun, jul, aug, sep, oct, nov, dec)
)AS pvt

Alternative Short Syntax For Last Anonymous Objective Variables Scope in C#

using namespace System.Windows.Forms;
    using(var od = new OpenFileDialog())
        {
            if (od.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // TO DO something futher   
            }
        }

------------------------

using namespace System.Windows.Forms;
   if((new OpenFileDialog()).ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                 // Reference to anonymous ShowDialog out of scope    
            }
        }

Wednesday, November 18, 2015

Easy Debugging ASP.NET MVC Application.

With increasing business demands now we develop very large and complex ASP.NET projects that take more time to compile and debug. And whenever QA reports any issue, we need to compile and debug the code with exact scenario. Then only we figure out the debugging information like which route, controller, model, view, class and DB queries with parameter values that help us in finding the root cause of an issue.
Life will be easy if we get all this debugging information on the page itself without any extra effort like debugging. For making it possible, we have Glimpse that helps us by providing this debugging information at runtime on the page itself and reducing our debugging time. Glimpse can be easily introduced into our application.
Glimpse is very helpful to get debugging information as well as performance detail.
Here I explain step by step, how we can use Glimpse into our application.

Contents

  1. What is Glimpse?
  2. How to setup Glimpse?
  3. How to enable/disable Glimpse?
  4. How to use Glimpse?
  5. Glimpse Tabs
  6. Glimpse Custom Configuration

1. What is Glimpse?

  • Glimpse is a diagnostic platform of web applications and provides the detailed debugging information on page like: Routing, Views, Controller, ModelBinding with properties, Database queries with parameter values, Configuration, Execution information.
  • Glimpse can be setup easily into a web application through the nuget.
  • Glimpse provides a detailed server side view while other available tools (Fiddler and the F-12 development tools) only provide a client side view.
  • Glimpse can be used in production environment also and it can be enabled or disabled based on custom configuration.
  • Glimpse can be used for ASP.NET Web form as well as ASP.NET MVC application.

2. How To Setup Glimpse

Download and install Glimpse into your application as per MVC version.
Glimpse can be installed in two ways, either by package manager console command or by Manage Nugget Package as below: For example: here we do it for MVC5 in Visual Studio 2013.
Open Manage Nuget Packages and search for Glimpse and install the below packages:
Search “Glimpse” and install Glimpse MVC5.
Search “Glimpse.ef” and install Glimpse EF6.
When you install Glimpse into your MVC project:
It adds below glimpse references into application:
  • Glimpse.Mvc5
  • Glimpse.AspNet
  • Glimpse (Core)
  • Glimpse.ADO
  • Glimpse.EF6
It adds minimal configuration required to your Web.Config file.
  • Definition for custom configuration node glimpse:
    <configSections>
      <section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />
    </configSections>
  • Define HTTP module and HTTP handler in system.web node:
    <httpModules>
      <add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
    </httpModules>
    <httpHandlers>
      <add path="glimpse.axd" verb="GET" 
      type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
    </httpHandlers>
  • Register HTTP module and HTTP handler in system.webserver node:
    <system.webServer>
      <modules>
        <add name="Glimpse" type="Glimpse.AspNet.HttpModule, 
        Glimpse.AspNet" preCondition="integratedMode" />
      </modules>
      <handlers>
        <add name="Glimpse" path="glimpse.axd" 
        verb="GET" type="Glimpse.AspNet.HttpHandler, 
        Glimpse.AspNet" preCondition="integratedMode" />
      </handlers>
    </system.webServer>
  • Add glimpse node at the end which can be used to configure Glimpse behavior as per your needs:
    <glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
    </glimpse>
  • We can add Glimpse as per the MVC and EF versionof our application.For MVC4 we can use below console command to install Glimpse
PM> Install-Package Glimpse.MVC4
PM> Install-Package Glimpse.EF5

3. Enable/Disable Glimpse for Application

  • Once Glimpse is installed to your project and when you run your application, then Glimpse plugin does not show up because it is disabled by default.
  • A Glimpse can be enabled/disabled by using the Turn ON/OFF button available on Glimpse.axd page as below and going through the URL: http://[your-url]/Glimpse.axd/.

4. How to Use Glimpse

  • After enabling Glimpse in application, Glimpse symbol (g) is shown at the bottom of the page.
  • By clicking this g symbol complete Glimpse Panel is displayed and it contains different Glimpse tabs which provide the Front-end to backend info.

5. Glimpse Tabs

  • Configuration Tab: It gives details about web.config entries, the application settings, the connection strings used, Web Authentication modes, the custom errors mode, Default redirect page, the Http handlers and Http Modules.
    Here we can see all the configuration details.
  • Routes Tab: The Routes tab shows the routes of the web application, along with default values and constraints. The matched route is highlighted for convenience.
    Here we can see how routes are defined and which route is being executed.
  • Execution Tab: The Execution tab shows the ASP.NET MVC execution pipeline of actions, action results and action filters (including child actions) required to respond to the HTTP request.
    Here, we can see execution sequence of actions.
  • SQL Tab: The SQL tab displays the DB query executed on this page.
    Here we can see DB query detail with parameters values 1000.
  • Trace Tab: The Trace tab shows any messages traced to System.Diagnostics.Trace orSystem.Diagnostics.Debug during the lifetime of the HTTP request. Glimpse automatically displays trace statements, eliminating the headache of digging through log files. Popular logging frameworks can be integrated with some slight configuration as well.
    Here, we can see the trace messages if we have used Trace/Debug into page code.
  • Request Tab: The Request tab shows basic HTTP request information as the server received it. Client-side web debuggers (such as FireBug) often show similar data, but as the browser sent it.Here, we can see the actual request.
  • Session Tab: The Session tab shows the data that is associated with the current requestor's session store.
    Here, we can see the session information if we have used session.
  • Views Tab: The Views tab displays all calls made to configured View Engine(s) and View(s).
  • Model Binding Tab: The Model Binding tab visualizes the ASP.NET MVC model binding sub-system, displaying information about the model binder(s) used for a HTTP request.
  • Metadata Tab: The Metadata tab shows the model metadata that ASP.NET MVC has used to display the view for the HTTP request.

6. Configuring Glimpse

  1. We can hide any particular tab in glimpse panel by adding the below code for example: Cache Tab
    <glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
        <tabs>
            <ignoredTypes>
             <add type="Glimpse.AspNet.Tab.Cache, Glimpse.AspNet "/>
    
           </ignoredTypes>
        </tabs>
    </glimpse>
  2. Glimpse can be disabled for specific pages by "uris" as below:
    <glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
    
    <runtimePolicies>
    <uris>
          <!--<add regex="/Employee/EmployeeAdd"/> -->
            <add regex=".*/Employee/*.*"/> 
        </uris>
    </runtimePolicies>
    </glimpse>
    Here, Glimpse will not work for Employee controller.
  3. Glimpse can be enabled permanently by the below code and then "Turn Off" option on "Glimpse.axd" page will not work for disabling it.
    <glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
          <runtimePolicies>
           <ignoredTypes>
             <add type="Glimpse.Core.Policy.ControlCookiePolicy, Glimpse.Core"/>
          </ignoredTypes>
         </runtimePolicies>
    </glimpse>
  4. Glimpse can be disabled permanently as below code and then "Glimpse.axd" page will not be available to enable/disable it.
    <glimpse defaultRuntimePolicy="Off" endpointBaseUri="~/Glimpse.axd">

How to get checked values of CheckBoxList in c# using by Linq?

 private string GetCheckedValues(CheckBoxList chkBoxList)
        {
            IEnumerable<string> selectedValues = chkBoxList.Items.Cast<ListItem>()
                             .Where(i => i.Selected)
                             .Select(i => i.Value);
            return string.Join("~", selectedValues);
        }

Thursday, October 15, 2015

How to find dependent table in Sql server?

select    s1.name as from_schema
,        s1.name+'.'+o1.Name as from_table
,        s2.name as to_schema
,        s2.name+'.'+o2.Name as to_table
from    sys.foreign_keys fk
inner    join sys.objects o1
on        fk.parent_object_id = o1.object_id
inner    join sys.schemas s1
on        o1.schema_id = s1.schema_id
inner    join sys.objects o2
on        fk.referenced_object_id = o2.object_id
inner    join sys.schemas s2
on        o2.schema_id = s2.schema_id

where    not    (    s1.name = s2.name
            and    o1.name = o2.name) and  o2.name='Your table name' 

Friday, September 18, 2015

how to show list in mvc with angular js?

   public JsonResult getList()
        {
            var Product = new List<Product>();

            Product = GetList1();
            return Json(Product, JsonRequestBehavior.AllowGet);
        }
        public List<Product> GetList1()
        {
            List<Product> prod = new List<Product>(){
             new Product { ProductId = 1, ProductName = "Tomato Soup", CategoryId = "Groceries", DisplayProductPrice = 1,ProductImage="1.jpg",OutOfStock="0",ProductSummary="jhjhj" },
            new Product { ProductId = 2, ProductName = "Yo-yo", CategoryId = "Toys", DisplayProductPrice = 3.75M ,ProductImage="1.jpg",OutOfStock="0",ProductSummary="jhjhj" },
            new Product { ProductId = 3, ProductName = "Hammer", CategoryId = "Hardware", DisplayProductPrice = 16.99M,ProductImage="1.jpg",OutOfStock="0",ProductSummary="jhjhj" }
    };

            return prod;
        }

------------------------------------



@{
    ViewBag.Title = "Product";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/ui-bootstrap-tpls-0.10.0.min.js"></script>
<link href="~/Scripts/bootstrap.min.css" rel="stylesheet" />
<script src="/Scripts/jquery-1.7.1.js"></script>

<script>
    var appProd = angular.module("appProd", ['ui.bootstrap']);
    appProd.filter('startFrom', function () {
        return function (input, start) {
            if (input) {
                start = +start; //parse to int
                return input.slice(start);
            }
            return [];
        }
    });
    appProd.controller("cntProduct", function ($scope, $http, $timeout, $modal, $log) {
        var catid = 0;
        $scope.list = [];
        $scope.entryLimit = 2;
        debugger;
        $.ajax({
            type: 'GET',
            contentType: 'application/json; charset=utf-8',
            url: '/Home/GetList',
            success: function (data) {
                debugger;
                window.alert(1);
                $scope.list = data;
                $scope.currentPage = 1;
                $scope.entryLimit = 2;
                $scope.filteredItems = $scope.list.length;
                $scope.totalItems = $scope.list.length;
                if (catid == '1') {
                    $scope.bClass = "selected";
                    $scope.mClass = "";
                } else {
                    $scope.bClass = "";
                    $scope.mClass = "selected";
                }
            },
            error: function (response) {
                debugger;
                window.alert(1);
            }
        });

        $scope.setPage = function (pageNo) {
            $scope.currentPage = pageNo;
        };
        $scope.filter = function () {
            debugger;
            $timeout(function () {
                $scope.filteredItems = $scope.filtered.length;
            }, 10);

        };

        $scope.getText = function (obj) {
            debugger;

            return obj.replace(' ', '-').replace('&', '-');
        };



    });
</script>
<div id="scartcontent" class="scartcontent" ng-app="appProd" ng-controller="cntProduct">
    <div class="clr pad10"></div>

    <div class="fright cart">
        <div>
            <span>
                <img src='../../images/card-img.jpg' width="31" height="28" alt="" align="absmiddle" /></span><span> hjuyjuyjuy
                 <a href="ViewBasket" title="go to shopping cart">
                     <img src='../../images/green-chkout.jpg' title="Checkout" alt="" align="absmiddle" class="margL10" />
                 </a>
                </span>
        </div>

    </div>
    <div class="cd-tabs">
        <nav>
            <ul class="cd-tabs-navigation">
                <li style="display: none;"><a class="{{bClass}}" n1111g-click="getProductList('1')">Book</a>
                </li>
                <li><a class="{{mClass}}" ng11111-click="getProductList('2')">Magazine</a>
                </li>
            </ul>
            <!-- cd-tabs-navigation -->
        </nav>
        <ul class="cd-tabs-content">
            <li class="selected">

                <div class="pad5">
                    <div class="fleft pad10">
                        PageSize:                        
                    <select ng-model="entryLimit">
                        <option>2</option>
                        <option>5</option>
                        <option>10</option>
                        <option>20</option>
                        <option>50</option>
                        <option>100</option>
                    </select>
                    </div>
                    <div class="fright pad10">
                        <input type="text" class="add_input2 pad5" ng-model="search" ng-change="filter()" id="txtSearch" placeholder="Search Book/Magazine here" />
                    </div>
                </div>
                <div class="clear"></div>
                <div class="gd-row" align="center">

                    <div class="gd-col gu3" ng-repeat="prod in filtered = (list | filter:{ProductName:search}) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">

                        <div class="product-unit">
                            <div class="center">
                                <a ng-disabled='{{prod.OutOfStock=="0"? false :true }}' ng-href="{{prod.CategoryId}}/{{prod.ProductId}}/PD/{{getText(prod.ProductName)}}">
                                    <img style="width: 103px; height: 142px" ng-src="../../Images/{{ prod.ProductImage}}" /></a>
                            </div>
                            <div class="pu-details">
                                <div class="height35">
                                    {{prod.ProductName}}-  {{prod.ProductSummary}}
                                </div>

                                <div class="pu-price margT8">
                                    <div class="pu-border-top padT5">
                                        <div class="margB5">Rs.{{prod.DisplayProductPrice}}</div>
                                    </div>
                                    <div class="pu-border-top"></div>
                                </div>
                                <div class='{{prod.OutOfStock=="0"? "avalb":"notavalb" }}'>
                                    {{prod.OutOfStock=="0"? "Available":"Out of Stock" }}
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
            </li>
        </ul>
        <div class="clear"></div>
        <div class="col-mid-10" style="background: #fff;">
            <div class="pad5">
                <div class="col-wid-10" ng-show="filteredItems == 0">
                    <h4>No Product found as per Search keyword </h4>
                </div>
            </div>
            <div class="clear"></div>
            <div class="fleft col-mid-10" ng-show="filteredItems > 0">
                <div class="fleft col-wid-3 pad10">
                    {{ "Showing " + (currentPage == 1 ? "1" : ((currentPage - 1) * entryLimit)+1) + " to " +
               ((currentPage * entryLimit) >= filteredItems ? filteredItems : (currentPage * entryLimit))
                 + " of " + filteredItems + " Items";}}
                </div>
                <div class="fright pagination-small margR10">
                    <div pagination="" page="currentPage" on-select-page="setPage(page)"
                        boundary-links="true" total-items="filteredItems" items-per-page="entryLimit"
                        previous-text="&laquo;" next-text="&raquo;">
                    </div>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="disclm">
        <strong>Disclaimer</strong>:- All Magazines listed at this site belongs to Publication Division, Ministry of Info. & Broadcasting, for any product related queries or issues customers will have to contact the ministry at 011-2436 7453, email-id pdjucir@gmail.com  for any product non-delivery / refund / quality or other issues related to the magazines listed here. Office of CGA (BharatKosh Portal Owner) will complete financial transaction related activity only.
    </div>
    <div class="clear"></div>

</div>
<div class="clr pad10"></div>
<div class="clr padB20"></div>

Tuesday, September 8, 2015

View basket

<%@ Page Title="" Language="C#" MasterPageFile="~/Common/PaymentMaster.Master" AutoEventWireup="true" CodeBehind="ViewProductBasket.aspx.cs" Inherits="CGA.CPSMS.ReceiptPortal.ViewProductBasket" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="Scripts/angular.js"></script>
    <style>
        .input {
            width: 45px;
        }
    </style>

    <script type="text/javascript">
        window.history.forward();
        function noBack() { window.history.forward(-1); }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div id="content" class="content">
        <div class="brdcrumb"><a href='<% =Page.ResolveUrl("~/Product")%>'>Product</a> > Your Basket</div>
        <div class="btmbrd">
            <span class="head">
                <asp:Label ID="lblcaption" Text="Your Basket" runat="server"></asp:Label>
            </span>
            <span class="fright">&nbsp;&nbsp;</span>
        </div>
        <div class="pad10">

            <script>
                var appProd = angular.module("appProd", []);
                appProd.directive('focus', function ($timeout, $parse) {
                    return {
                        link: function (scope, element, attrs) {
                            var model = $parse(attrs.focus);
                            scope.$watch(model, function (value) {
                                if (value === true) {
                                    $timeout(function () {
                                        element[0].focus();
                                    });
                                }
                            });
                        }
                    };
                });

                appProd.directive('onlyNum', function () {
                    return function (scope, element, attrs) {
                        var keyCode = [8, 9, 37, 39, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 110];
                        element.bind("keydown", function (event) {
                            $('#ctl00_ContentPlaceHolder1_imgLoad').show();
                            var vv = event.which;
                            var cc = this.value.length + 1;
                            if ($.inArray(event.which, keyCode) == -1) {
                                scope.$apply(function () {
                                    scope.$eval(attrs.onlyNum);
                                    $('#ctl00_ContentPlaceHolder1_imgLoad').hide();
                                    event.preventDefault();
                                });
                                event.preventDefault();
                            } else if ((vv != 8 && cc > 6)) {
                                $('#ctl00_ContentPlaceHolder1_imgLoad').hide()
                                event.preventDefault();
                            }
                            $('#ctl00_ContentPlaceHolder1_imgLoad').hide();

                        });
                    };
                });

                appProd.controller("cntProduct", function ($scope, $http) {
                    var dataObj = { value: '1' };

                    var res1 = $http.post('PublicationCartWebService.asmx/getBasketItem', dataObj);
                    res1.success(function (data, status, headers, config) {
                        $('#ctl00_ContentPlaceHolder1_imgLoad').show();
                        $scope.basket = eval(data.d);
                        $scope.isBasketEmpty = $scope.basket.length;
                        $scope.FocusIndex = 100;
                        $scope.number = 5;
                        $('#ctl00_ContentPlaceHolder1_imgLoad').hide();
                     
                    });
                    $scope.processed = 0;
                    var resTotalCount = $http.post('PublicationCartWebService.asmx/GetTotalCount', dataObj);
                    resTotalCount.success(function (data, status, headers, config) {
                        $scope.ShowItem = eval(data.d);

                    });
                    var resGrandTotalPrice = $http.post('PublicationCartWebService.asmx/getTotalPrice', dataObj);
                    resGrandTotalPrice.success(function (data, status, headers, config) {
                        $scope.GrandTotalPrice = eval(data.d);
                    });
                    $scope.TotalShowing = function () {
                        var resTotalCount = $http.post('PublicationCartWebService.asmx/GetTotalCount', dataObj);
                        resTotalCount.success(function (data, status, headers, config) {
                            $scope.ShowItem = eval(data.d);

                        });

                    };
                    $scope.TotalPrice = function () {
                        $scope.processed = 0;
                        var resTotalCount = $http.post('PublicationCartWebService.asmx/getTotalPrice', dataObj);
                        resTotalCount.success(function (data, status, headers, config) {
                            $scope.GrandTotalPrice = eval(data.d);


                        });


                    };

                    $scope.getNumber = function (num) {
                        return new Array(num);
                    };

                    $scope.saveItems = function (ProductAttributeMappingId, ProductItemPrice, qty) {
                        $scope.FocusIndex = qty.$index;
                        $scope.processed = 0;
                        $('#ctl00_ContentPlaceHolder1_imgLoad').show();
                        var qtyProd = qty.item.TotalQty;
                        var qtyProd1 = qty.item.Stock;
                        if (qtyProd <= qtyProd1 && qtyProd > 0 && qtyProd1 > 0) {
                         
                            var dataObj = { ProductAttributeMappingId: ProductAttributeMappingId, ProductItemPrice: ProductItemPrice, Quantity: qtyProd };
                            var res1 = $http.post('PublicationCartWebService.asmx/AddItem', dataObj);
                            res1.success(function (data, status, headers, config) {
                                $scope.basket = eval(data.d);
                                $scope.TotalPrice();
                                $scope.TotalShowing();
                                $('#ctl00_ContentPlaceHolder1_imgBtnCheckOut').show();
                                $('#ctl00_ContentPlaceHolder1_imgLoad').hide();


                            });
                        }
                        else {

                            if (qtyProd > 0) {

                                window.alert('Quantity entered must be less than or equal to stock available');
                                var dataObj11 = { value: '1' };
                                qty.item.TotalQty = '';
                                var res11 = $http.post('PublicationCartWebService.asmx/getBasketItem', dataObj11);
                                res11.success(function (data, status, headers, config) {
                                    $scope.basket = eval(data.d);
                                    $scope.isBasketEmpty = $scope.basket.length;
                                    $('#ctl00_ContentPlaceHolder1_imgBtnCheckOut').show();
                                    $('#ctl00_ContentPlaceHolder1_imgLoad').hide();
                                });
                            } else {

                                if (qty.item.TotalQty == 0) { qty.item.TotalQty = ''; } else {

                                    window.alert('Quantity must be greater than 0');
                                }
                                $('#ctl00_ContentPlaceHolder1_imgLoad').hide();
                                $('#ctl00_ContentPlaceHolder1_imgBtnCheckOut').hide();
                                $scope.processed = 1;

                            }
                        };

                    };

                    $scope.Remove = function (ProductAttributeMappingId) {
                        $scope.processed = -1;
                        if (window.confirm("Are you sure to remove product from basket?")) {
                            var dataObj = { ProductAttributeMappingId: ProductAttributeMappingId };
                            var res1 = $http.post('PublicationCartWebService.asmx/RemoveItem', dataObj);
                            res1.success(function (data, status, headers, config) {
                                $scope.basket = eval(data.d);
                                $scope.isBasketEmpty = $scope.basket.length;
                                $scope.TotalShowing();
                                $scope.TotalPrice();
                                $('#ctl00_ContentPlaceHolder1_imgBtnCheckOut').show();

                            });
                        }
                    }
                    $scope.ImageExist = function (url) {
                        var img = new Image();
                        img.src = url;
                        if (img.height == 0) { return 'ProductImages/' + url; } else {
                            return '/ProductImages/1.jpg'
                        }
                    };

                });

            </script>
            <div ng-app="appProd" ng-controller="cntProduct">

                <div class="col-mid-10" align="center" id="imgLoad" runat="server" style="position: absolute; height: 150px; width: 1000px; z-index: 999; margin: auto 0;">
                    <img src='<% =Page.ResolveUrl("~/App_Themes/Receipt/images/loading-x.gif")%>' style="height: 150px; width: 200px;" />
                </div>

                <div ng-show="isBasketEmpty >0" class="gd-row">
                    <table class="data1" cellpadding="0" cellspacing="0" ng-show="isBasketEmpty > 0">
                        <tr class="data1-head">
                            <td class="col-mid-2">&nbsp;</td>
                            <td class="col-mid-2">Product Description</td>
                            <td class="col-mid-2">Unit Price</td>
                            <td class="col-mid-1">Qty.</td>
                            <td class="col-mid-1">Sub Total</td>
                            <td class="col-mid-1"></td>
                        </tr>
                        <tr ng-repeat="item in basket">
                            <td>
                                <img style="width: 65px; height: 83px;" ng-src="{{ImageExist(item.ProductImage)}}"></td>
                            <td>
                                <span>{{item.ProductName}}</span><br />
                                <span>Subscription: {{item.ProductIssues}}</span><br />
                                <span>Language: {{item.ProductLanguage}}</span><br />
                                <span>Country: {{item.ProductCountry}} </span>

                            </td>
                            <td>Rs.{{item.ItemPrice.toFixed(2)}}</td>
                            <td>
                               <%-- <input  class="input" type="text" only-num name='{{$index}}' id='{{$index}}' ng-model="item.TotalQty"
                                    ng-change="saveItems(item.ProductAttributeMappingId,item.ItemPrice,this)" focus="{{FocusIndex==$index? true:false}}" />--%>
                             
                                <select ng-model="item.TotalQty"  class="input" ng-change="saveItems(item.ProductAttributeMappingId,item.ItemPrice,this)">                                    
                                    <option ng-repeat="i in getNumber(item.Stock) track by $index"" >{{$index+1}}</option>                                  
                                </select>
                            </td>
                            <td>Rs. {{(item.ItemPrice*item.TotalQty).toFixed(2) }}</td>
                            <td title="remove from cart">
                                <span>
                                    <a href="" ng-click="Remove(item.ProductAttributeMappingId)">
                                        <img src='<% =Page.ResolveUrl("~/App_Themes/Receipt/images/delete-icon.jpg")%>' alt="" /></a>
                                </span></td>
                        </tr>



                    </table>

                    <div class="grandtotal">
                        <div class="fleft col-mid-6">
                            Cart Summary: You have <strong>{{ShowItem}}</strong>  in your shopping cart.
                        </div>
                        <div class="fright col-mid-3">
                            <table class="fright">
                                <tr>
                                    <td class="col-mid-7"></td>
                                    <td class="col-mid-3"><strong></strong>
                                    </td>
                                </tr>
                                <tr>

                                    <td><strong>Grand Total: &nbsp;&nbsp; Rs. {{GrandTotalPrice}}</strong>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="pad10 margT8">
                        <span class="fleft" style="width: 70%;"><a href="Product">
                            <img src='<% =Page.ResolveUrl("~/App_Themes/Receipt/images/continue-shipping.jpg")%>' title="Continue Shopping" width="206" height="33" alt="" /></a> </span>
                        <span class="fleft" style="width: 30%">
                            <div id="divShow" ng-show="processed >0" style="color: red; font-weight: bold;" runat="server">Quantity required to proceed further</div>
                            <div id="divShow1" ng-show="processed<1" runat="server">
                                <asp:ImageButton ID="imgBtnCheckOut" ImageUrl="~/App_Themes/Receipt/images/sml-place-order.jpg" ToolTip="Place  Order" runat="server" OnClick="imgBtnCheckOut_Click" />
                            </div>
                        </span>
                    </div>
                </div>
                <div ng-show="isBasketEmpty ==0" class="gd-row">
                    <b style="padding-left: 16px;">No product added in your basket.</b>
                    <div class="clearfix"></div>

                    <div class="pad10 margT8">
                        <span class="fleft" style="width: 70%;"><a href="Product">
                            <img src='<% =Page.ResolveUrl("~/App_Themes/Receipt/images/continue-shipping.jpg")%>' title="Continue Shopping" width="206" height="33" alt="" /></a> </span>

                    </div>
                </div>
            </div>
            <div class="clr"></div>
        </div>
        <div class="disclm">
            <strong>Disclaimer</strong>:- All Magazines listed at this site belongs to Publication Division, Ministry of Info. & Broadcasting, for any product related queries or issues customers will have to contact the ministry at 011-2436 7453, email-id pdjucir@gmail.com  for any product non-delivery / refund / quality or other issues related to the magazines listed here. Office of CGA (BharatKosh Portal Owner) will complete financial transaction related activity only.
        </div>
        <br />
    </div>
</asp:Content>