Thursday 15 March 2018

MVC asp.net Multi Level Menu Bind


Model:


public class M_MenuModel
    {
        #region Variable
        public Int32   MMID { get; set; }
        public string MM_Name { get; set; }
        public string MM_Url { get; set; }
        public Int32 MM_Parent { get; set; }     
        public string MM_Icon { get; set; }       
        #endregion
    }

Controller :

 public ActionResult UserMenuShow()
        {
            ViewBag.Menu = BuildMenu();
            return View();
        }


 private IList<M_MenuModel> BuildMenu()
        {
IList<M_MenuModel> mmList = new List<M_MenuModel>(){
             
                // Parent
                new M_MenuModel(){ MMID = 1, MM_Name = "Home", MM_Parent = 0, MM_Url = "1"} ,
                new M_MenuModel(){ MMID = 2, MM_Name = "Admin", MM_Parent = 0, MM_Url = "1"} ,
                new M_MenuModel(){ MMID = 3, MM_Name = "Accounting", MM_Parent = 0, MM_Url = "1"} ,

                // Children

                new M_MenuModel() { MMID=21, MM_Name = "Create User", MM_Parent = 2, MM_Url="1", MM_Icon="" },
                new M_MenuModel() { MMID=22, MM_Name = "Create Group", MM_Parent = 2, MM_Url="2" },
                new M_MenuModel() { MMID=23, MM_Name = "Create Account", MM_Parent = 2, MM_Url="3"},

                new M_MenuModel() { MMID=31, MM_Name = "Manage Account", MM_Parent = 3, MM_Url="1" },
                new M_MenuModel() { MMID=32, MM_Name = "GL Accounts", MM_Parent = 3, MM_Url="2" },


                new M_MenuModel() { MMID=321, MM_Name = "Salary Accounts", MM_Parent = 32, MM_Url="1" },
                new M_MenuModel() { MMID=322,MM_Name = "Savings Accounts", MM_Parent = 32, MM_Url="2" },

            };

            return mmList;
}


View:



@{
    List<ProjectName.Areas.Admin.Models.M_MenuModel> menuList = ViewBag.Menu;
}


@foreach (var mp in menuList.Where(p => p.MM_Parent == 0))
                {

                    <li>

                        @if (menuList.Count(p => p.MM_Parent == mp.MMID) > 0)
                        {
                            <a href="#@mp.MM_Name" data-toggle="collapse" class="collapsed">@mp.MM_Name <i class="icon-submenu lnr lnr-chevron-left"></i></a>
                            @:<div ID="@mp.MM_Name" class="collapse">
                                @:<ul class="nav">
        }
                        @if (menuList.Count(p => p.MM_Parent == mp.MMID) == 0)
                        {
                            
                            @:<a href="@mp.MM_Url"> @Html.Raw(@mp.MM_Icon) @mp.MM_Name </a>
                        }

                            @RenderMenuItem(menuList, mp)

                        @if(menuList.Count(p => p.MM_Parent == mp.MMID) > 0)
                        {



                    @:</ul>
                        
                    @:</div>
                                            }

                    </li>
                }

@helper RenderMenuItem(List<Manav_Ashraya_V1.Areas.Admin.Models.M_MenuModel> menuList, Manav_Ashraya_V1.Areas.Admin.Models.M_MenuModel mi)
{
foreach (var cp in menuList.Where(p => p.MM_Parent == mi.MMID))
{


        @:<li>








    if (menuList.Count(p => p.MM_Parent == cp.MMID) > 0)
    {

            <a href="#@cp.MM_Name.Replace(' ','_')" data-toggle="collapse" class="collapsed">@cp.MM_Name <i class="icon-submenu lnr lnr-chevron-left"></i></a>

            @:<div ID="@cp.MM_Name.Replace(' ','_')" class="collapse">
                @:<ul class="nav">
        }
        if (menuList.Count(p => p.MM_Parent == cp.MMID) == 0)
        {
            @:<a href="@cp.MM_Url">@cp.MM_Name</a>


        }

        @RenderMenuItem(menuList, cp)
    if (menuList.Count(p => p.MM_Parent == cp.MMID) > 0)
    {
     @:   </ul>

    @:</div>
    }
    else
    {


         
        @:</li>
    }
}
}

Friday 9 March 2018

Update a table using JOIN in SQL Server

  1. UPDATE t1  
  2. SET t1.TID = t2.DOID  
  3. FROM dbo.Table1 AS t1  
  4. INNER JOIN dbo.Table2 AS t2  
  5. ON t1.CommonField = t2.[Common Field] 

Saturday 3 March 2018

Populate (Bind) DropDownList using AngularJS AJAX and JSON

Angular JS 

var AnguarModule = angular.module('CMS', []);
AnguarModule.controller('DashBoard', function ($scope, $http, ApiCall) {
  var result = ApiCall.GetApiCall("MasterDetails", "ASYears").success(function (data) {
        $scope.ASYearsDetails = data;
        $scope.ASYearsD = $scope.ASYearsDetails[0];
    });
});

AngularService

AnguarModule.service('ApiCall', ['$http', function ($http) {
    var result;

    // This is used for calling get methods from web api
    this.GetApiCall = function (controllerName, methodName) {
        result = $http.get(controllerName + '/' + methodName).success(function (data, status) {
            result = (data);

        }).error(function () {
            alert("Something went wrong");
        });
        return result;
    }; 
 

} ]);



HTML: 

 <div class="content" ng-app="CMS">

<div class="col-lg-4  col-md-6" ng-controller="DashBoard">

<select ng-model="ASYearsD" ng-options="items.ASYears for items in ASYearsDetails"
                ng-change="ShowUnfiled()" ng-init="ASYearsD = data[1].AsYr" id="ASYearsD">
                <option value="">-- Select --</option>
            </select>
</div>
</div>


JSON :


[{"AsYr":"2017","ASYears":"2016-17","Selected":"1"},{"AsYr":"2016","ASYears":"2015-16","Selected":"0"},{"AsYr":"2015","ASYears":"2014-15","Selected":"0"},{"AsYr":"2014","ASYears":"2013-14","Selected":"0"},{"AsYr":"2013","ASYears":"2012-13","Selected":"0"},{"AsYr":"2012","ASYears":"2011-12","Selected":"0"},{"AsYr":"2011","ASYears":"2010-11","Selected":"0"},{"AsYr":"2010","ASYears":"2009-10","Selected":"0"},{"AsYr":"2009","ASYears":"2008-09","Selected":"0"},{"AsYr":"2008","ASYears":"2007-08","Selected":"0"},{"AsYr":"2007","ASYears":"2006-07","Selected":"0"}]




Wednesday 31 January 2018

SQL CharIndex Example

  1. DECLARE @PW_MPID NVARCHAR(max)  
  2. set @PW_MPID='1555|2555|35|'  
  3.   
  4. DECLARE @PW_MPIDPostion Varchar(max) = CHARINDEX('|',@PW_MPID)                                                                                      
  5. rint @PW_MPIDPostion                                                       
  6. DECLARE @TempPW_MPID Varchar(max)                                                                                          
  7. WHILE(@PW_MPIDPostion > 0)                                                   
  8.          BEGIN                          
  9.                SET @TempPW_MPID = SUBSTRING(@PW_MPID ,1,@PW_MPIDPostion-1)       
  10.                print @TempPW_MPID  
  11.                  
  12.                 SET @PW_MPID =SUBSTRING(@PW_MPID,@PW_MPIDPostion +1,LEN(@PW_MPID))                                                     
  13.                       print @PW_MPID                                                                     
  14.    SET @PW_MPIDPostion  = CHARINDEX('|',@PW_MPID)     
  15.    print @PW_MPIDPostion                                        
  16.  END   

Tuesday 30 January 2018

ROLES AND RESPONSIBILITIES

Sr .Net Developer Responsibilities and Duties

If you are considering a job as Sr .Net Developer here is a list of the most standard responsibilities and duties for the Sr .Net Developer position.

Design, develop, test, support and deploy desktop, custom web, and mobile applications.

Gather customer software requirements and develop related software applications and programs.

Research and evaluate software related technologies and products.

Design and develop testing and maintenance procedures and activities.

Develop and write high quality coding that meets customer requirements.

Create software documentation and update existing documentation.

Design, develop and implement critical applications in a .Net environment.

Assist and support other team members on multiple projects.

Drive team members to keep up with projects deadlines and within the clients’ budgets.

Implement best practices, standards and procedures including quality and delivery methodologies.

Ensure compliance with the documented software processes and procedures throughout the life cycle of software products.

Senior Developer Responsibilities and Duties

If you are considering a job as Senior Developer here is a list of the most standard responsibilities and duties for the Senior Developer position.

Develop and document design, source base and architecture.

Maintain and manage existing source bases.

Design, develop and implement solutions to users’ needs and requirements.

Review and improvise code.

Run tests and fix bugs.

Coordinate with architects and business analysts to determine functionalities.

Develop technical solutions to complex business problems.

Design and develop technical solutions for enterprise-level projects.

Design and develop data analysis solutions.

Design and develop logical and physical data models that meet application requirements.

Senior Programmer Responsibilities and Duties

If you are considering a job as Senior Programmer here is a list of the most standard responsibilities and duties for the Senior Programmer position.

Architect, develop and implement software programs to meet business requirements.

Develop application code and modules for business and technical requirements.

Tune up design for maintainability, scalability and efficiency.

Develop and implement programs, designs and codes.

Design and develop systems, sub-systems and programs.

Coordinate and support technical staff, operations and vendors.

Interact with clients to determine their requirements and needs.

Resolve and troubleshoot problems and complex issues.

Perform unit tests and fix bugs.

Integrate best qualitative practices in design and development aspects of programs

Senior Software Engineer Roles & Responsibilities…

If you are considering a job as Senior Software Engineer here is a list of the most standard responsibilities and duties for the Senior Software Engineer position.

Design, develop and implement applications that support day-to-day operations.

Provide innovative solutions to complex business problems.

Plan, develop and implement large-scale projects from conception to completion.

Develop and architect lifecycle of projects working on different technologies and platforms.

Interface with clients and gather business requirements and objectives.

Translate clients’ business requirements and objectives into technical applications and solutions.

Understand and evaluate complex data models.

Design, develop and implement new integration.

Execute system development and maintenance activities.

Develop solutions to improvise performance and scalability of systems.

Software Developer Responsibilities and Duties

If you are considering a job as Software Developer here is a list of the most standard responsibilities and duties for the Software Developer position.

Evaluate, assess and recommend software and hardware solutions.

Develop software, architecture, specifications and technical interfaces.

Develop user interfaces and client displays.

Design, initiate and handle technical designs and complex application features.

Develop, deliver and test software prototypes.

Assist software personnel in handling ongoing tasks as required.

Build flexible data models and seamless integration points.

Innovate and develop high-value technology solutions to streamline processes.

Initiate and drive major changes in programs, procedures and methodology.

Coordinate with other developers and software professionals.

Software Programmer Responsibilities and Duties

If you are considering a job as Software Programmer here is a list of the most standard responsibilities and duties for the Software Programmer position.
Design and develop systems integration, related issues and processes.

Perform analysis, design and develop computer programs and applications.

Perform unit testing and maintain software programs and applications.

Perform coding data acquisition routines and access issues.

Develop custom reports for large data sets.

Assist and support in integration of GIS analysis applications.

Develop and deploy unit testing, load testing and tracking system software support.

Configure, maintain and support production databases.

Develop and implement application to application data feeds.

Configure and maintain multi-site data processes and issues including synchronization.

Software Engineer Responsibilities and Duties 

If you are considering a job as Software Engineer here is a list of the most standard responsibilities and duties for the Software Engineer position.

Design, develop and manage software projects for clients.

Analyze and evaluate user needs and develop software solutions.

Write supporting documents for projects developed and tested.

Develop Microsoft .net based web applications.

Develop MS SQL server applications like views, triggers and stored procedures.

Design and develop web user interfaces with back-end databases and other tools.

Recommend technical feasibilities and solutions.

Evaluate new technologies in the light of emerging trends and technologies.

Modify and update existing technologies improvise performances.

Troubleshoot and resolve difficult problems relating to software applications and programs.

Software Analyst Responsibilities and Duties

If you are considering a job as Software Analyst here is a list of the most standard responsibilities and duties for the Software Analyst position.

Perform complex analysis, designing and programming to meet business requirements.

Maintain, manage and modify all software systems and applications.

Define specifications for complex software programming applications.

Interface with end-users and software consultants.

Develop, maintain and manage systems, software tools and applications.

Resolve complex issues relating to business requirements and objectives.

Coordinate and support software professionals in installing and analyzing applications and tools.

Analyze, develop and implement testing procedures, programming and documentation.

Train and develop other software analysts.

Analyze, design and develop modifications and changes to existing systems to enhance performance.

Software Architect Responsibilities and Duties

If you are considering a job as Software Architect here is a list of the most standard responsibilities and duties for the Software Architect position.

Develop, leverage and architect technical solutions to scale business initiatives.

Develop roadmaps for subsystems in accordance with product related technologies.

Execute product related technologies, technology platforms, architects and design principles and advancements.

Design, develop and architect evolution applications across multi-generation product releases.

Generate business requirements, verify, validate and implement.

Architect all software development lifecycle including requirements gathering, designing, implementing, testing, and releasing.

Architect and implement appropriate technologies according to business requirements.

Assess and evaluate technology tradeoffs.

Select technologies to architect product roadmaps.

Develop and implement appropriate technologies to troubleshoot functional issues and risks.

Software Consultant Responsibilities and Duties

If you are considering a job as Software Consultant here is a list of the most standard responsibilities and duties for the Software Consultant position.

Analyze and understand detailed business requirements.

Provide mapping requirements and software solutions.

Provide recommendations for software developments and implementations.

Document business requirements, gatherings and issues and updated business process flows.

Document results of software research tools and applications.

Execute program modifications and changes.

Interface with clients, software professionals and consultants to develop solutions applications.

Review and evaluate technical design and technical quality issues and processes.

Coordinate and collaborate workflow processes and issues in designing, programming and testing.

Develop highly functional qualitative modifications and system changes.

Software Designer Responsibilities and Duties

If you are considering a job as Software Designer here is a list of the most standard responsibilities and duties for the Software Designer position.

Design, develop and execute unit test plans, test designs, test cases and test strategies.

Design, develop and execute subsystem test plans, procedures and processes.

Document all test plans, test cases and strategies procedures and issues.

Design and implement test scripts on test tools and scripting languages.

Coordinate and collaborate with outside test partners.

Design, develop and implement program and process improvements.

Design and develop coding, code reviews, unit testing and release management.

Develop design specifications in accordance with business requirements and issues.

Recommend strategic improvements to optimize performances.

Perform analyses and interpretations of strategies and software applications.

Monday 15 January 2018

SQL Server: Make all UPPER case to Proper Case/Title Case

CREATE FUNCTION [dbo].[fnConvert_TitleCase] (@InputString VARCHAR(4000) )
RETURNS VARCHAR(4000)
AS
BEGIN
DECLARE @Index INT
DECLARE @Char CHAR(1)
DECLARE @OutputString VARCHAR(255)

SET @OutputString = LOWER(@InputString)
SET @Index = 2
SET @OutputString = STUFF(@OutputString, 1, 1,UPPER(SUBSTRING(@InputString,1,1)))

WHILE @Index <= LEN(@InputString)
BEGIN
    SET @Char = SUBSTRING(@InputString, @Index, 1)
    IF @Char IN (' ', ';', ':', '!', '?', ',', '.', '_', '-', '/', '&','''','(')
    IF @Index + 1 <= LEN(@InputString)
BEGIN
    IF @Char != ''''
    OR
    UPPER(SUBSTRING(@InputString, @Index + 1, 1)) != 'S'
    SET @OutputString =
    STUFF(@OutputString, @Index + 1, 1,UPPER(SUBSTRING(@InputString, @Index + 1, 1)))
END
    SET @Index = @Index + 1
END

RETURN ISNULL(@OutputString,'')
END

Friday 12 January 2018

Using WebGet and WebInvoke with example

Using WebGet and WebInvoke
Services can be exposed using the WebHttpBinding binding using either the WebGet or WebInvoke attributes. Each of these attributes specifies the HTTP verb, message format, and body style needed to expose an operation. We will examine each of these attributes and reasons to use each.

WebGet
The WebGet attribute exposes operations using the GET verb. The GET has significant advantages over other HTTP verbs. First, the endpoint is directly accessible via a Web browser by typing the URI to the service into the address bar. Parameters can be sent within the URI either as query string parameters or embedded in the URI. Second, clients and other downstream systems such as proxy servers can easily cache resources based on the cache policy for the service. Because of the caching capability, the WebGet attribute should be used only for retrieval.

WebInvoke
The WebInvoke attribute exposes services using other HTTP verbs such as POST, PUT, and DELETE. The default is to use POST, but it can be changed by setting the Method property of the attribute. These operations are meant to modify resources; therefore, the WebInvoke attribute is used to make modifications to resources.

Shows a service that defines services that are exposed in the WebGet and WebInvoke attributes. The WebGet attribute is used to retrieve customer information. The WebInvoke attribute is used for those operations that modify data such as adding or deleting customers. Last, the UriTemplate property is specified on WebGet and WebInvoke attribute to identify a customer resource using the URI.



  • using System;  
  • using System.ServiceModel;  
  • using System.ServiceModel.Web;  
  •   
  • namespace WCFExample  
  • {  
  •     [ServiceContract]  
  •     public class CustomerService  
  •     {  
  •         [OperationContract]  
  •         [WebGet(UriTemplate="/customer/{id}")]  
  •         public Customer GetCustomer(int id)  
  •         {  
  •             Customer customer = null;  
  •   
  •             // Get customer from database  
  •   
  •             return customer;  
  •         }  
  •   
  •         [OperationContract]  
  •         [WebInvoke(Method = "PUT", UriTemplate = "/customer/{id}")]  
  •         public void PutCustomer(int id, Customer customer)  
  •         {  
  •             // Put customer in database  
  •         }  
  •   
  •         [OperationContract]  
  •         [WebInvoke(Method = "DELETE", UriTemplate = "/customer/{id}")]  
  •         public void DeleteCustomer(int id)  
  •         {  
  •             // Put customer in database  
  •         }  
  •     }  
  • }  
  • Upload valid file in C#

        protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile)     {         try         {             Dictionary<string, byte[]>...