Pages

Tuesday, November 26, 2013

Analysis Services - Errors when trying to add a User as a Server Admin OR "The following system error occasdsurred: No mapping between account names and security IDs was done. .(Microsft.AnalysisServices)"

Thursday, September 19, 2013

Building Apps with HTML5

HTML5 and Microsoft Developer Tools:

Beyond Microsoft’s involvement with the W3C and the HTML5 technologies supported in the browser, there’s another dimension to Microsoft’s approach to HTML5 that’s important for developers: its approach to HTML5 tooling.
In early 2011, Microsoft updated two of its development tools with service packs: Visual Studio 2010 and Expression Web 4. The service packs for both of these tools provided an HTML5 document type for validation, as well as IntelliSense for new HTML5 tags and attributes. If you’re using Visual Studio 2010 SP1, you can enable the HTML5 Schema by clicking Tools | Options | Text Editor | HTML | Validation, and then selecting the HTML5 option in the Target drop-down list, as shown in Figure 1. You can also set HTML5 as the default schema from the HTML Source Editing Toolbar in any HTML file, as shown in Figure 2.
Enabling the HTML5 Schema via the Options Dialog
Figure 1 Enabling the HTML5 Schema via the Options Dialog
Setting the HTML5 Schema on the HTML Source Editing Toolbar
Figure 2 Setting the HTML5 Schema on the HTML Source Editing Toolbar
Once your default schema is set, you’ll gain IntelliSense support in Visual Studio for the 28 new semantic tags in HTML, as well as new tag-specific and global attributes, as show in Figure 3.
HTML5 IntelliSense in Visual Studio 2010 SP1
Figure 3 HTML5 IntelliSense in Visual Studio 2010 SP1
Microsoft further updated its HTML5 support with its release of the Web Standards Update for Microsoft Visual Studio 2010 SP1 in June 2011. This extension, which works with all editions of Visual Studio 2010, adds further HTML5 IntelliSense and validation to Visual Studio, includes JavaScript IntelliSense for new browser capabilities like Geolocation and DOM Storage, and provides comprehensive CSS3 IntelliSense and validation. You can download this extension, which will be regularly updated to provide enhanced tooling for HTML5 development, from bit.ly/m7OB13.
For Expression Web 4 SP1, setting the HTML5 schema under Tools | Page Options offers the same IntelliSense, and the tool also provides CSS3 IntelliSense for several draft CSS3 modules like border-radius, box-shadow, transform and the like.
If you’re using WebMatrix (see http://www.microsoft.com/web/webmatrix/next/), you may have noticed that all new .html, .cshtml or .vbhtml documents you create contain default markup similar to what’s shown in Figure 4. As I’ll discuss in the next article in this series, this is a basic, valid HTML5 document. Most notably, the doctype and meta charset tags have lost a lot of cruft. Using this simple doctype triggers HTML5 mode across all modern browsers, and WebMatrix makes it easier for you by providing an HTML5 document by default.
Figure 4 A Default HTML Document in WebMatrix
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.   <head>
  4.     <meta charset="utf-8" />
  5.     <title></title>
  6.   </head>
  7.   <body></body>
  8. </html>
If that’s not enough new HTML5 tooling for you—all since January 2011, by the way—ASP.NET MVC recently got in on the fun with the ASP.NET MVC 3 Tools Update announced at MIX11 in April. Along with a number of other great new tooling features, the ASP.NET MVC 3 Tools Update provides the option to use the HTML5 doctype for new projects—and ships Modernizr 1.7 in the Scripts folder of new applications. Modernizr is a JavaScript library that greatly eases HTML5 development; I’ll discuss it in depth in a future article.
The takeaway here is that even though HTML5 is just emerging in our browsers, official tool support is quickly being added, and Microsoft is even adding support for libraries (like Modernizr) from the community. You can target HTML5 with some help from Microsoft tools today, and expect that that HTML5 support will continue to grow and improve over time.

‘Adopting’ HTML5 in Your Applications

By now, you should realize that HTML5 isn’t a single entity that you can adopt or migrate to in one fell swoop. Adopting HTML5, rather than being a wholesale choice, is about making a technology-by-technology evaluation and determining which technologies are right for your application. For each HTML5 technology you evaluate, look at (at least) the following factors when deciding whether that technology is ready for you to adopt:
  1. How widely implemented across all major browsers is the technology?
  2. How would you adopt this technology and “polyfill” support for browsers that don’t support a given feature?
The first factor is the most important, and when combined with an understanding of the browsers commonly used by visitors to your site, should give you a clear picture of which subset of the 100-plus specifications is worth evaluating further. That subset should consist of a set of stable specifications you can reliably adopt today for your users.
However, even with that stable set of HTML5 technologies, you shouldn’t ignore your users who haven’t moved to a newer browser. If you’re heavily involved in the day-to-day development for your site, you no doubt have some rough idea of the percentages of users visiting your site with a given browser. For most of us, it would be easy to look at the percentage of users visiting with an older browser and come to the conclusion that adopting any HTML5 technologies would negatively impact those users. Luckily there’s “polyfilling” to save us from waiting until some foggy date in the future to adopt HTML5.
Paul Irish (a developer on the jQuery and Modernizr projects) defines a polyfill as “… a shim that mimics a future API, providing fallback functionality to older browsers.” A polyfill is like spackle for your Web sites; it’s a way to determine if a given HTML5 feature is available to the user currently browsing your site, and to provide either a shim that “fills in” that support or a course of graceful degradation that enables your site to still function fully.
The most popular library associated with polyfilling is Modernizr, the JavaScript library I mentioned earlier. Modernizr provides some basic polyfills for semantic markup, feature detection for major HTML5 technologies and support for conditional CSS based on supported features. As noted, Modernizr will be the subject of an upcoming article; it will also feature prominently (along with many other polyfilling libraries) throughout this series. To learn more, download Modernizr at modernizr.com.
When it comes to choosing which technologies to adopt, your final list may be a combination of widely supported specifications and other specifications for which you’ll have to polyfill support for certain browsers. Only you will know the exact makeup of that list based on your current needs and context.
In the coming months, I’ll discuss several notable specifications, from Geolocation and Forms and Canvas, to Web Workers, Web Sockets and IndexedDB. Some of these are widely supported and “site-ready,” and some, like Web Sockets, are too groundbreaking to ignore, regardless of where they stand today. With each specification, I’ll discuss current and known future support, some basics about how you can implement the specification’s features on your sites, and how to polyfill support for browsers that don’t support a given feature.

 

Monday, August 26, 2013

Calendar Scheduler In MVC4

Calendar Scheduler:using DHXScheduler dll

Code In Controller:
 public class CalendarController : Controller
    {
      Entities1 entity = new Entities1();
        public ActionResult Index()
        {
            //Being initialized in that way, scheduler will use CalendarController.Data as a the datasource and CalendarController.Save to process changes
            var scheduler = new DHXScheduler(this);

            /*
             * It's possible to use different actions of the current controller
             *      var scheduler = new DHXScheduler(this);  
             *      scheduler.DataAction = "ActionName1";
             *      scheduler.SaveAction = "ActionName2";
             *
             * Or to specify full paths
             *      var scheduler = new DHXScheduler();
             *      scheduler.DataAction = Url.Action("Data", "Calendar");
             *      scheduler.SaveAction = Url.Action("Save", "Calendar");
             */

            /*
             * The default codebase folder is ~/Scripts/dhtmlxScheduler. It can be overriden:
             *      scheduler.Codebase = Url.Content("~/customCodebaseFolder");
             */
         

            scheduler.InitialDate = new DateTime(2012, 09, 03);

            scheduler.LoadData = true;
            scheduler.EnableDataprocessor = true;

            return View(scheduler);
        }
     

        public ContentResult Data()
        {

            var data = new SchedulerAjaxData(new eCRM_MastersEntities1().Events);
                                     
            return (ContentResult)data;
        }

        public ContentResult Save(eCRM_Entity.Event updateevents, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            entity = new eCRM_MastersEntities1();

            try
            {
                //var changedEvent = (Tbl_Calendar)DHXEventsHelper.Bind(typeof(Tbl_Calendar), actionValues);



                switch (action.Type)
                {
                    case DataActionTypes.Insert:
                        //do insert
                        entity.Events.Add(updateevents);

                        break;
                    case DataActionTypes.Delete:
                        //do delete
                        break;
                    default:// "update"                        
                        //do update
                        break;
                }
                entity.SaveChanges();
                action.TargetId = updateevents.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return (ContentResult)new AjaxSaveResponse(action);
        }
    }

In Model:
using System;
    using System.Collections.Generic;

    public partial class Event
    {
        public int id { get; set; }
        public string text { get; set; }
        public System.DateTime start_date { get; set; }
        public System.DateTime end_date { get; set; }
        public Nullable<int> UserId { get; set; }
    }

In View
@{
    Layout = "~/Views/Shared/_UserLayout.cshtml";
    ViewBag.Title = "Event Calender";
}




 <h2 class="topHeader">
    Events Details:</h2>
    <br />
    <div style="height:700px;width:900px;">
        @Html.Raw(Model.Render())
    </div>

Add  DHXScheduler  Dll :



Example :


Friday, August 2, 2013

Create Layout In MVC4

Create Layout In MVC4:

1.Create SideMenu With Header Page
2.Create SideMenu Page
3.Create Layout Page.

Layout  Example Code:


<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
 <script src="../../Content/prefixfree-1.0.7.js" type="text/javascript"></script>
 <link href="../../Content/Menu.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <script src="../../Content/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../../Content/prefixfree-1.0.7.js" type="text/javascript"></script>
<link href="../../Content/sidemenu.css" rel="stylesheet" type="text/css" />
    
</head>
<body>
    <div>
    <table style="width:100%;height:50%">

<tr >
<td style="width:45%;top:auto;margin-left:20%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../Content/Images/Untitled.png" /></td>

<td style="margin-left:32%;height:50%">@Html.Partial("Menu") </td>
</tr>
<tr></tr>
</table>



<table style="width:100%">


<tr valign="top">
<td style="width:15%;top:auto" valign="top"> @Html.Partial("Sidemenu")</td>
<td style="width:85%;background-color:White;height:600px;">
        @RenderBody()
        </td>
</tr>


</table>

<div style="height:100px;background-color:Yellow;">
</div>
    </div>
</body>
</html>

My Layout Page:
 

Question How Call Page In Your Pages:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "Your page title";
    }


Hope It will help you.....enj

Dynamic Controls In MVC using Jquery

Dynamic Controls In MVC4 using Jquery:


    View Code:


@using (Html.BeginForm("AddShippingLocation", "Location", "POST"))
{
        <input type="hidden" id="hdncountryid"  />;
        <input type="hidden" id="hdnstateid"  />;
        <input type="hidden" id="hdncityeid" />;
        
                                              
                                              
    <input type="hidden" id="hdnAddress1"  />;
        <input type="hidden" id="hdnAddress2"  />;
        <input type="hidden" id="hdnZipCode" />;                                              
                                              
        <input type="hidden" id="hdnPhone"  />;
        <input type="hidden" id="hdnExtension"  />;
        <input type="hidden" id="hdnFax" />;                                          
                                              
                                              
                                              
 eCRM.Controllers.eCRM_Masters.LocationController dp = new eCRM.Controllers.eCRM_Masters.LocationController();

         eCRM_Entity.eCRM_MastersEntities1 entities = new eCRM_Entity.eCRM_MastersEntities1();
         List<SelectListItem> list = new List<SelectListItem>();
         list.Add(new SelectListItem { Text = "-Select Country-", Value = "Selects items" });
         var cat = (from c in entities.tbl_Country select c).ToArray();
         for (int i = 0; i < cat.Length; i++)
         {
             list.Add(new SelectListItem
             {
                 Text = cat[i].CountryName,
                 Value = cat[i].CountryId.ToString(),
                 Selected = (cat[i].CountryId == 0)
             });
         }
         ViewData["danhsach"] = list;
  
<div>
    <legend>***********Shipping Address**********</legend>
</div>
<div id='AppSelectorGroup'>
    <div id="AppSelectorBox_1" style="display: block; float: left;">

        <div class="editor-field">
       
            &nbsp;&nbsp;
    @Html.DropDownList("CountryId", (IEnumerable<SelectListItem>)ViewData["danhsach"],
            new { @class = "CssCategory", id = "CountryId" })


            @Html.DropDownList("State_Id", new SelectList("State_Id", "StateName"), new { @class = "CssSubcategory", id = "State_Id" })
          @Html.DropDownList("CityId", new SelectList("CityId", "CityName"), new { @class = "CssSubcategorycity", id = "CityId" })
              
            &nbsp;&nbsp;
           Address1
             @Html.TextBox("Address1", null, new { id = "Address11" })
            Address2
             @Html.TextBox("Address2", null, new { id = "Address21" })
            &nbsp;&nbsp;
           ZipCode
             @Html.TextBox("ZipCode", null, new { id = "ZipCode1" })
            &nbsp;&nbsp;
             Phone
             @Html.TextBox("Phone", null, new { id = "Phone1" })
            &nbsp;&nbsp;
             Extension
             @Html.TextBox("Extension", null, new { id = "Extension1" })
           Fax
             @Html.TextBox("Fax", null, new { id = "Fax1", @class = "deleteAppselector" })
        </div>
    </div>



    <div class="clear-fix"></div>
</div>
 <p>
    <input type="submit" value="Save" name="Command" id="btn1" />
        <input type="submit" value="Cancel" name="Command"  />
 </p>


//Page Validation

<script type="text/javascript">

    $("#btn1").click(function (e) {
        debugger;
        //        e.preventDefault();
        var CountryId = $('#CountryId option:selected').val();
        var StateId = $('#State_Id option:selected').val();
        var CityId = $('#CityId option:selected').val();
        if (CountryId == 0) {
            alert("Please select country.")
            return false;
        }
        if (StateId == 0) {
            alert("Please select State.")
            return false;
        }
        if (CityId == 0) {
            alert("Please select City.")
            return false;
        }
        var address1 = $("#Address11").val();
        if (address1 == '') {
            alert("Please enter address1");
            return false;
        }
        var Address21 = $("#Address21").val();
        if (Address21 == '') {
            alert("Please enter Address2");
            return false;
        }
        var ZipCode1 = $("#ZipCode1").val();
        if (ZipCode1 == '') {
            alert("Please enter ZipCode");
            return false;
        }
        var Phone1 = $("#Phone1").val();
        if (Phone1 == '') {
            alert("Please enter Phone");
            return false;
        }
        var Extension1 = $("#Extension1").val();
        if (Extension1 == '') {
            alert("Please enter Extension");
            return false;
        }
        var Fax1 = $("#Fax1").val();
        if (Fax1 == '') {
            alert("Please enter Fax");
            return false;
        }

        ///////////////////////////

        var hdncountryid = $("#hdncountryid").val();
        var CountryId2 = $(hdncountryid + ' option:selected').val();

        var hdnstateid = $("#hdnstateid").val();
        var StateId2 = $(hdnstateid + ' option:selected').val();

        var hdncityeid = $("#hdncityeid").val();
        var Cityid2 = $(hdncityeid + ' option:selected').val();


        ///////////////////////////////
        //        var CountryId = $('#CountryId option:selected').val();
        //        var StateId = $('#State_Id option:selected').val();
        //        var CityId = $('#CityId option:selected').val();
        if (CountryId2 == 0) {
            alert("Please select country.")
            return false;
        }
        if (StateId2 == 0) {
            alert("Please select State.")
            return false;
        }
        if (Cityid2 == 0) {
            alert("Please select City.")
            return false;
        }
        var address11 = $("#hdnAddress1").val();
        if (address11 == '') {
            alert("Please enter address1");
            return false;
        }
        var Address212 = $("#hdnAddress2").val();
        if (Address212 == '') {
            alert("Please enter Address2");
            return false;
        }
        var ZipCode12 = $("#hdnZipCode").val();
        if (ZipCode12 == '') {
            alert("Please enter ZipCode");
            return false;
        }
        var Phone11 = $("#hdnPhone").val();
        if (Phone11 == '') {
            alert("Please enter Phone");
            return false;
        }
        var Extension11 = $("#hdnExtension").val();
        if (Extension11 == '') {
            alert("Please enter Extension");
            return false;
        }
        var Fax11 = $("#hdnFax").val();
        if (Fax11 == '') {
            alert("Please enter Fax");
            return false;
        }





    });

    $('#CountryId').change(function () {

        var CountryId = $(this).val();
        var URLS1 = '@Url.Action("GetState")' + '?CountryId=' + CountryId;

        $.getJSON(URLS1, function (dataS1) {
            $('#State_Id').html(dataS1);


        });
    });

    $('#State_Id').change(function () {
        var StateId = $(this).val();
        var URLC1 = '@Url.Action("GetCity")' + '?StateId=' + StateId;

        $.getJSON(URLC1, function (dataC1) {

            $('#CityId').html(dataC1);


        });

    });

//Dropdown Selection Change event...
    function onSelectChangeCountry() {

        var hdncountryid = $("#hdncountryid").val();
        var CountryId = $(hdncountryid + ' option:selected').val();
        var URLS1 = '@Url.Action("GetState")' + '?CountryId=' + CountryId;

        $.getJSON(URLS1, function (dataS1) {
            var hdnstateid = $("#hdnstateid").val();
            $(hdnstateid).html(dataS1);


        });
    }


    function onSelectChangeState() {
        var hdnstateid = $("#hdnstateid").val();
        var StateId = $(hdnstateid + ' option:selected').val();
        var URLC1 = '@Url.Action("GetCity")' + '?StateId=' + StateId;

        $.getJSON(URLC1, function (dataC1) {
            var hdncityeid = $("#hdncityeid").val();

            $(hdncityeid).html(dataC1);


        });
    }

</script>



//Dynamic Code ...For Genrate DropDownlist and Text Boxs//

<script type="text/javascript">

    //Jquery for handling the Click Event and Creating the Dynamic Controls:
    //----------Begin: For Creating App Selector Groups---------------//
    var deleteAppSelectror = $(".deleteAppselector").length;

    /* For Adding the Control */


    $("#addAppSelector").click(function () {

        debugger;
        if (deleteAppSelectror == 10) {
            $("#addAppSelector").hide();
            $("#removeAppSelector").show();
            //alert("Only 10 URLs are allowed");
            return false;
        }
        else {
            $("#addAppSelector").show();
            $("#removeAppSelector").show();
        }
        deleteAppSelectror++;
        var newTextBoxDiv = $(document.createElement('div'))
         .attr("id", 'AppSelectorBox__' + deleteAppSelectror);
        var URL = '@Url.Action("Getcountry")';

        newTextBoxDiv.append('<div class="editor-label"><label>Shipping Address: </label></div>' +

        '<select name="CountryId"  onChange="onSelectChangeCountry();" id="CountryId' + deleteAppSelectror + '" class="valid" style = "width:80px"> </select>'

             +
              '&nbsp;&nbsp;&nbsp;<select name="State_Id" onChange="onSelectChangeState();" id="State_Id' + deleteAppSelectror + '" class="valid" style = "width:80px"> </select>' +
               '&nbsp;&nbsp;&nbsp;<select name="CityId"  id="CityId' + deleteAppSelectror + '" class="valid" style = "width:80px"> </select>' +


                'Address1<div class="editor-field"><input type="text" name="Address1" id="Address1' + deleteAppSelectror + '" value="" />' +


                'Address2<input type="text" name="Address2" id="Address2' + deleteAppSelectror + '" style="margin-left:8px;" value="" />' +
              'ZipCode<input type="text" name="ZipCode" id="ZipCode' + deleteAppSelectror + '" style="margin-left:8px;" value="" />' +
              'Phone<input type="text" name="Phone" id="Phone' + deleteAppSelectror + '" style="margin-left:8px;" value="" />' +
              'Extension<input type="text" name="Extension" id="Extension' + deleteAppSelectror + '" style="margin-left:8px;" value="" />' +
               'Fax<input type="text" name="Fax" class="deleteAppselector" id="Fax' + deleteAppSelectror + '" style="margin-left:8px;" value="" />' +

                '</div><div class="clear-fix"></div>');

        $.getJSON(URL, function (data) {
            var ddlcountry = '#CountryId' + deleteAppSelectror;


            $(ddlcountry).html(data);

            var ddlstate = '#State_Id' + deleteAppSelectror;
            var ddlcity = '#CityId' + deleteAppSelectror;


            $("#hdncountryid").val(ddlcountry);
            $("#hdnstateid").val(ddlstate);
            $("#hdncityeid").val(ddlcity);

            var Address1 = '#Address1' + deleteAppSelectror;
            var Address2 = '#Address2' + deleteAppSelectror;
            var ZipCode = '#ZipCode' + deleteAppSelectror;
            var Phone = '#Phone' + deleteAppSelectror;
            var Extension = '#Extension' + deleteAppSelectror;
            var Fax = '#Fax' + deleteAppSelectror;

            $("#hdnAddress1").val(Address1);
            $("#hdnAddress2").val(Address2);
            $("#hdnZipCode").val(ZipCode);
            $("#hdnPhone").val(Phone);
            $("#hdnExtension").val(Extension);
            $("#hdnFax").val(Fax);
        })

        newTextBoxDiv.appendTo("#AppSelectorGroup");


        if (deleteAppSelectror == 10) {
            $("#addAppSelector").hide();
            $("#removeAppSelector").show();

            return false;
        }
        return true;
    });
    /* For Removing the Control */
    $("#removeAppSelector").click(function () {
        debugger;
        if (deleteAppSelectror == 1) {
            $("#removeAppSelector").hide();
            $("#addAppSelector").show();
            return false;
        }
        else {
            $("#removeAppSelector").show();
            $("#addAppSelector").show();
        }

        $('.deleteAppselector').last().parent().parent().remove();
        deleteAppSelectror--;
        if (deleteAppSelectror == 1) {
            $("#removeAppSelector").hide();
            $("#addAppSelector").show();
            return false;
        }
        return true;
    });

    //----------End: For Creating App Selector Groups---------------//

</script>
  

               
}



Hope it will help u...enj...

Thursday, August 1, 2013

Entity Framework-Bind Data In Grid usind Stored Procedure -MVC4

Bind Data In Grid usind Stored Procedure

Step1: Create Stored Procedure..

Step2: Create edmx File and Add Your table and Stored procddures...

Step3:Genrate  Code Generation Form edmx file...


Step4: This For Only Get data from SP.


Step5:  

Ofter Genrate Your Model1.Context.tt From .edmx file...

Add /Edit/Delete Operation From Stored Procedure:
  set Parameters: 
  public virtual int xp_Potential_AddUpdateDelete(Nullable<int> potentialId, string potentialTitle, Nullable<int> potenOwnr_EmpID, string accountName, string accountId, string contactName, string contactId, string potential_Type, string primary_CampaginSrc, Nullable<System.DateTime> close_Date, Nullable<int> stageId, string probablity, string approxAmount_Product, string approxAmount_Services, string total_ApproxAmount, string nextStep, string description, Nullable<int> leadSourceId, Nullable<int> prev_TaskID_Active, Nullable<int> accnt_ActivityId, Nullable<int> user, Nullable<int> opration, ObjectParameter status)
        {
            var potentialIdParameter = potentialId.HasValue ?
                new ObjectParameter("PotentialId", potentialId) :
                new ObjectParameter("PotentialId", typeof(int));
   
            var potentialTitleParameter = potentialTitle != null ?
                new ObjectParameter("PotentialTitle", potentialTitle) :
                new ObjectParameter("PotentialTitle", typeof(string));
   
            var potenOwnr_EmpIDParameter = potenOwnr_EmpID.HasValue ?
                new ObjectParameter("PotenOwnr_EmpID", potenOwnr_EmpID) :
                new ObjectParameter("PotenOwnr_EmpID", typeof(int));
   
            var accountNameParameter = accountName != null ?
                new ObjectParameter("AccountName", accountName) :
                new ObjectParameter("AccountName", typeof(string));
   
            var accountIdParameter = accountId != null ?
                new ObjectParameter("AccountId", accountId) :
                new ObjectParameter("AccountId", typeof(string));
   
            var contactNameParameter = contactName != null ?
                new ObjectParameter("ContactName", contactName) :
                new ObjectParameter("ContactName", typeof(string));
   
            var contactIdParameter = contactId != null ?
                new ObjectParameter("ContactId", contactId) :
                new ObjectParameter("ContactId", typeof(string));
   
            var potential_TypeParameter = potential_Type != null ?
                new ObjectParameter("Potential_Type", potential_Type) :
                new ObjectParameter("Potential_Type", typeof(string));
   
            var primary_CampaginSrcParameter = primary_CampaginSrc != null ?
                new ObjectParameter("Primary_CampaginSrc", primary_CampaginSrc) :
                new ObjectParameter("Primary_CampaginSrc", typeof(string));
   
            var close_DateParameter = close_Date.HasValue ?
                new ObjectParameter("Close_Date", close_Date) :
                new ObjectParameter("Close_Date", typeof(System.DateTime));
   
            var stageIdParameter = stageId.HasValue ?
                new ObjectParameter("StageId", stageId) :
                new ObjectParameter("StageId", typeof(int));
   
            var probablityParameter = probablity != null ?
                new ObjectParameter("Probablity", probablity) :
                new ObjectParameter("Probablity", typeof(string));
   
            var approxAmount_ProductParameter = approxAmount_Product != null ?
                new ObjectParameter("ApproxAmount_Product", approxAmount_Product) :
                new ObjectParameter("ApproxAmount_Product", typeof(string));
   
            var approxAmount_ServicesParameter = approxAmount_Services != null ?
                new ObjectParameter("ApproxAmount_Services", approxAmount_Services) :
                new ObjectParameter("ApproxAmount_Services", typeof(string));
   
            var total_ApproxAmountParameter = total_ApproxAmount != null ?
                new ObjectParameter("Total_ApproxAmount", total_ApproxAmount) :
                new ObjectParameter("Total_ApproxAmount", typeof(string));
   
            var nextStepParameter = nextStep != null ?
                new ObjectParameter("NextStep", nextStep) :
                new ObjectParameter("NextStep", typeof(string));
   
            var descriptionParameter = description != null ?
                new ObjectParameter("Description", description) :
                new ObjectParameter("Description", typeof(string));
   
            var leadSourceIdParameter = leadSourceId.HasValue ?
                new ObjectParameter("LeadSourceId", leadSourceId) :
                new ObjectParameter("LeadSourceId", typeof(int));
   
            var prev_TaskID_ActiveParameter = prev_TaskID_Active.HasValue ?
                new ObjectParameter("Prev_TaskID_Active", prev_TaskID_Active) :
                new ObjectParameter("Prev_TaskID_Active", typeof(int));
   
            var accnt_ActivityIdParameter = accnt_ActivityId.HasValue ?
                new ObjectParameter("Accnt_ActivityId", accnt_ActivityId) :
                new ObjectParameter("Accnt_ActivityId", typeof(int));
   
            var userParameter = user.HasValue ?
                new ObjectParameter("user", user) :
                new ObjectParameter("user", typeof(int));
   
            var oprationParameter = opration.HasValue ?
                new ObjectParameter("opration", opration) :
                new ObjectParameter("opration", typeof(int));
   
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("xp_Potential_AddUpdateDelete", potentialIdParameter, potentialTitleParameter, potenOwnr_EmpIDParameter, accountNameParameter, accountIdParameter, contactNameParameter, contactIdParameter, potential_TypeParameter, primary_CampaginSrcParameter, close_DateParameter, stageIdParameter, probablityParameter, approxAmount_ProductParameter, approxAmount_ServicesParameter, total_ApproxAmountParameter, nextStepParameter, descriptionParameter, leadSourceIdParameter, prev_TaskID_ActiveParameter, accnt_ActivityIdParameter, userParameter, oprationParameter, status);
        }


And Get Data Function:
  public virtual ObjectResult<xp_getAllPotential_Result> xp_getAllPotential()
        {
            ((IObjectContextAdapter)this).ObjectContext.MetadataWorkspace.LoadFromAssembly(typeof(xp_getAllPotential_Result).Assembly);
   
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<xp_getAllPotential_Result>("xp_getAllPotential");
        }


Controllers Class:


Add/Edit/Delete for Sp:

     [HttpPost]
        public ActionResult CreateEditPotential(CS_Potential mCust, string Command)
        {
            // Validate the model being submitted
            int oprat =  Convert.ToInt32(Command);

            if (!ModelState.IsValid)
            {

                return PartialView("_Potential", mCust);

            }
                   tbl_Potential mobjcust=new tbl_Potential();

                   if (oprat == 0)
                   {
                       mobjcust.PotentialId =  0;
                   }
                   else
                   {
                       mobjcust.PotentialId = mCust.PotentialId;
                       oprat = 0;
                   }
                    mobjcust.PotentialTitle=mCust.PotentialTitle;
                    mobjcust.PotenOwnr_EmpID=mCust.PotenOwnr_EmpID;
                    mobjcust.AccountName=mCust.AccountName;
                    mobjcust.AccountId=mCust.AccountId;
                    mobjcust.ContactName=mCust.ContactName;
                    mobjcust.ContactId=mCust.ContactId;
                    mobjcust.Potential_Type=mCust.Potential_Type;
                    mobjcust.Primary_CampaginSrc = mCust.Primary_CampaginSrc;

                    mobjcust.Close_Date=null;//mCust.Close_Date
                    mobjcust.StageId=null;//mCust.StageId
                    mobjcust.Probablity="";//mCust.Probablity
                    mobjcust.ApproxAmount_Product="";//mCust.ApproxAmount_Product
                    mobjcust.ApproxAmount_Services="";//mCust.ApproxAmount_Services
                    mobjcust.Total_ApproxAmount="";//mCust.Total_ApproxAmount
                    mobjcust.NextStep="";//mCust.NextStep
                    mobjcust.Description="";//mCust.Description
                    mobjcust.LeadSourceId=null;//mCust.LeadSourceId
                    mobjcust.Prev_TaskID_Active = 1;// null;//mCust.Prev_TaskID_Active
                    mobjcust.Accnt_ActivityId=null;//mCust.Accnt_ActivityId
                    mobjcust.CreatedBy=1;//mCust.CreatedBy
                  
                    int check = mobjModel.Potential_AddUpdateDelete(mobjcust, oprat);
                    if (check == 2 || check == 3 || check == 4)
                {
                    TempData["Msg"] = "Data has been saved succeessfully";
                    ModelState.Clear();
                    return RedirectToAction("TaskPotentialGrid", "C_Potential");
                }

            return PartialView("_Potential");
        }


   public ActionResult Edit(int id)
        {
            var data = mobjModel.GetPotential1(id);

            if (Request.IsAjaxRequest())
            {
                CS_Potential cust = new CS_Potential();
                cust.PotentialTitle = data.PotentialTitle;
                cust.PotentialId = data.PotentialId;
                cust.PotenOwnr_EmpID = data.PotenOwnr_EmpID;
                cust.AccountName = data.AccountName;
                cust.AccountId = data.AccountId;
                cust.ContactName = data.ContactName;
                cust.ContactId = data.ContactId;
                cust.Potential_Type = data.Potential_Type;
                cust.Primary_CampaginSrc = data.Primary_CampaginSrc;


                ViewData["EmpTitle"] = GetUsers();

                ViewBag.IsUpdate = true;
                return View("_Potential", cust);
            }
            else

                return View(data);
        }


        public ActionResult Delete(int id)
        {
            tbl_Potential mobjcust = new tbl_Potential();
            int oprat = 1;
            mobjcust.PotentialId= id;
            mobjcust.Prev_TaskID_Active = 18;
           
            int check = mobjModel.Potential_AddUpdateDelete(mobjcust,oprat);
            if (check==4)
            {
                TempData["Msg"] = "Data has been Deleted succeessfully";
                ModelState.Clear();
                return RedirectToAction("TaskPotentialGrid", "C_Potential");
            }
            else
            {
                return PartialView("_Potential");
            }

        } 





   Get Data Function For Bind :

    public ActionResult TaskPotentialGrid(int page = 1, string sort = "name", string sortDir = "ASC")
        {
            const int pageSize = 5;
            var totalRows = mobjModel.CountPotential();

            sortDir = sortDir.Equals("desc", StringComparison.CurrentCultureIgnoreCase) ? sortDir : "asc";

            var validColumns = new[] { "TaskStatusId", "TaskStatus", "CreatedDate", "IsActive" };
            if (!validColumns.Any(c => c.Equals(sort, StringComparison.CurrentCultureIgnoreCase)))
                sort = "TaskStatusId";
           
            var task = mobjModel.GetPotentialPage(page, pageSize, "it." + sort + " " + sortDir);

            var data = new PagedCustomerModel()
            {
                TotalRows = totalRows,
                PageSize = pageSize,
                Task = task
            };
            return View(data);
        }




Model Class Code:

   Add/Edit/Delete for Sp:

public int Potential_AddUpdateDelete(tbl_Potential Pt,int opration)
        {
            if (Pt.PotentialId == 0 && opration==0) //Add
            {
                AllOpration(Pt, opration);
                return 2;
            }
            else if (Pt.PotentialId > 0 && opration==1) //Delete
            {
                AllOpration(Pt, opration);
                return 4;
            }
            else if (Pt.PotentialId > 0 && opration==0)  //update
            {
                AllOpration(Pt, opration);
                return 3;
            }
            else
            {
                return 1;
            }

        } 

 public bool AllOpration(tbl_Potential Pt, int oprat)
        {

            System.Data.Entity.Core.Objects.ObjectParameter result = new System.Data.Entity.Core.Objects.ObjectParameter("Status", typeof(int));
            result.Value = DBNull.Value;

            entities.xp_Potential_AddUpdateDelete(Pt.PotentialId, Pt.PotentialTitle, Pt.PotenOwnr_EmpID, Pt.AccountName, Pt.AccountId, Pt.ContactName, Pt.ContactId, Pt.Potential_Type, Pt.Primary_CampaginSrc, Pt.Close_Date, Pt.StageId, Pt.Probablity, Pt.ApproxAmount_Product, Pt.ApproxAmount_Services, Pt.Total_ApproxAmount, Pt.NextStep, Pt.Description, Pt.LeadSourceId, Pt.Prev_TaskID_Active, Pt.Accnt_ActivityId, Pt.CreatedBy, oprat, result);

            if (result.Equals(2) || result.Equals(3) || result.Equals(4))
            {
                return true;
            }

            else
            {
                return false;
            }
            //return false;
        } 


Get data For .edmx file

   public List<CS_Potential> GetPotentialPage(int pageNumber, int pageSize, string searchCriteria)
        {
            if (pageNumber < 1)
                pageNumber = 1;

           // return entities.xp_getAllPotential();
                //  .OrderBy(searchCriteria)
                //.Skip((pageNumber - 1) * pageSize)
              //.Take(pageSize)
              //.ToList();



                entities=new eCRM_MastersEntities1();
                var data =
                    (from pt in entities.xp_getAllPotential()
                     select new CS_Potential
                     {
                         PotentialId = pt.PotentialId,
                         PotentialTitle = pt.PotentialTitle,
                         Name=pt.Name,
                         AccountName=pt.AccountName,
                         ContactName = pt.ContactName,
                         ContactId = pt.ContactId,
                         AccountId=pt.AccountId
                     }
                    ).ToList();
                return data;
              
        
                 }



View Page:


@model BAL.MS_PotentialMaster

@{
    ViewBag.Title = "M_Potential";
   
     WebGrid grid = new WebGrid(rowsPerPage: Model.PageSize);
     if(Model.TotalRows>0)
     {
     grid.Bind(Model.Potential,
               autoSortAndPage: false,
               rowCount: Model.TotalRows);
     }
}


<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>

<script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.20.min.js" type="text/javascript"></script>


<link href="../../Content/themes/base/minified/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function () {

        $("#CreateCustomer").live("click", function (e) {
            // e.preventDefault(); use this or return false
            var url = $(this).attr('href');
            $("#dialog-edit").dialog({
                title: 'Create Potential Stage',
                autoOpen: false,
                resizable: false,
                height: 200,
                width: 400,
                show: { effect: 'drop', direction: "up" },
                modal: true,
                draggable: true,
                open: function (event, ui) {
                    $(this).load(url);

                },
                close: function (event, ui) {
                    $(this).dialog('close');
                }
            });

            $("#dialog-edit").dialog('open');
            return false;
        });

        $(".editDialog").live("click", function (e) {
            // e.preventDefault(); use this or return false
            var url = $(this).attr('href');
            $("#dialog-edit").dialog({
                title: 'Edit Potential Stage',
                autoOpen: false,
                resizable: false,
                height: 200,
                width: 400,
                show: { effect: 'drop', direction: "up" },
                modal: true,
                draggable: true,
                open: function (event, ui) {
                    $(this).load(url);

                },
                close: function (event, ui) {
                    $(this).dialog('close');
                }
            });

            $("#dialog-edit").dialog('open');
            return false;
        });

        $(".confirmDialog").live("click", function (e) {

            // e.preventDefault(); use this or return false
            var url = $(this).attr('href');

            $("#dialog-confirm").dialog({
                autoOpen: false,
                resizable: false,
                height: 170,
                width: 350,
                show: { effect: 'drop', direction: "up" },
                modal: true,
                draggable: true,
                buttons: {
                    "OK": function () {
                        $(this).dialog("close");
                        window.location = url;

                    },
                    "Cancel": function () {
                        $(this).dialog("close");

                    }
                }
            });
            $("#dialog-confirm").dialog('open');
            return false;
        });

        $(".viewDialog").live("click", function (e) {
            // e.preventDefault(); use this or return false
            var url = $(this).attr('href');
            $("#dialog-view").dialog({
                title: 'View Potential Stage',
                autoOpen: false,
                resizable: false,
                height: 150,
                width: 400,
                show: { effect: 'drop', direction: "up" },
                modal: true,
                draggable: true,
                open: function (event, ui) {
                    $(this).load(url);

                },
                buttons: {
                    "Close": function () {
                        $(this).dialog("close");

                    }
                },
                close: function (event, ui) {
                    $(this).dialog('close');
                }
            });

            $("#dialog-view").dialog('open');
            return false;
        });

        $("#btncancel").live("click", function (e) {
            // location.reload(true);
            $("#dialog-edit").dialog('close');

        });
    });  
</script>

@using (Html.BeginForm("M_Potential", "M_Potential", FormMethod.Post, new { enctype = "multipart/form-data" }))

   
     
    <table style="margin-top:10px; border:1 solid Gray; padding-top:50;" cellpadding="0" cellspacing="0">
      <tr>
      <td colspan="2">
       <div style="color: Red; font-weight:bold;">
    @TempData["msg"] 
 
  <br />
  </div>
      </td>
      </tr>
    <tr>
    <td>
  
  
    @Html.LabelFor(m => m.PotentialStage)
        
    </td>
    <td>
     @Html.TextBoxFor(m => m.PotentialStage)
   
   <span style=" color:Red;">
  
    @Html.ValidationMessageFor(m => m.PotentialStage)
   </span>
   

    </td>
   
    </tr>

    <tr>
    <td></td>
    <td align="left" >
    <input type="submit" value="Add potential Stage" id="btnSubmit" />
   
    </td>
    </tr>
    </table>
    
    <table>
    <tr>
    <td colspan="2">
    <div>
     @if (Model.PotentialStageId > 0)
     {
   @* <table style="margin-top:10px; border:1 solid Gray; padding-top:50;" cellpadding="0" cellspacing="0">
    <tr>
     <td class="editor-label">
            @Html.LabelFor(model => model.PotentialStage)
        </td>
        <td class="editor-field">
            @Html.DisplayTextFor(model => model.PotentialStage)
        </td>
    </tr>
    <tr>
    <td class="editor-label">
            @Html.LabelFor(model => model.CreatedDate)
        </td>
        <td class="editor-field">
            @Html.DisplayTextFor(model => model.CreatedDate)
        </td>
       </tr>

      </table>
    *@
 
     }
    </div>
   
 @if (Model.TotalRows > 0)
 {
     <br />
    @grid.GetHtml(
    fillEmptyRows: false,
    tableStyle:"WebGrid",
  
         headerStyle: "webgrid-header",
         footerStyle: "webgrid-footer",
               alternatingRowStyle: "webgrid-alternating-row",
         selectedRowStyle: "webgrid-selected-row",
               rowStyle: "webgrid-row-style", htmlAttributes: new { id = "grid" },
    mode: WebGridPagerModes.All,
            firstText: "<< First",
            previousText: "< Prev",
            nextText: "Next >",
            lastText: "Last >>",
            columns: new[] {
       
        grid.Column("PotentialStageId", header: "Stage ID", canSort: false),
        grid.Column("PotentialStage",  header: "Stage Name",
        format: @<text> @Html.ActionLink((string)item.PotentialStage, "View", new { id = item.PotentialStageId }, new { @class = "viewDialog" })</text>
          ),
        grid.Column("CreatedDate", header: "Created Date",format: (item) => string.Format("{0:dd-MMM-yyyy}", item.CreatedDate)),
        grid.Column("", header: "Actions",format: @<text>
        @Html.ActionLink("Edit", "Edit", new { id = item.PotentialStageId }, new { @class = "editDialog"/*, data_dialog_id = "edit-Dialog"*/ })
 |      @Html.ActionLink("Delete", "Delete", new { id = item.PotentialStageId }, new { @class = "confirmDialog" })
         </text>
        )
    })
 }
 else
 {
       <p>No data found.</p>  
          
 }
   
    </td>
   
    </tr>



   
    </table>
    <div id="dialog-confirm" style="display: none">
    <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
        Are you sure to delete ?
    </p>
</div>
<div id="dialog-edit" style="display: none">
</div>
<div id="dialog-view" style="display: none">
</div>
  
   

}


Hope It will Help You...Enj..

Code Written by Anjum Syend and me...