Thursday, 2 February 2017

Highcharts in Asp.net

1. Open visual studio and create MVC project
2. Create a SQL Server Database table named "VehicleSummary".

3. Enter some data in the table.


4. Add Controller named HighchartsController.cs.
5. Write code in controller to get VehiclaSummary.


public static DataSet GetVehicleSummary()
        {
            SqlConnection con = new SqlConnection(str);
            string query = "Select * from VehicleSummary";
            SqlCommand cmd = new SqlCommand(query,con);
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
        
            return ds;
        }


6. Now we will create a model to hold this data and it to the controller:

public class Summary
        {
            public int Item { get; set; }
            public string Value { get; set; }
        }

7. Now return JSON  to get table values.

 [HttpGet]
        public JsonResult VehicleSummary()
        {
            List<Summary> lstSummary = new List<Summary>();

            foreach (DataRow dr in GetVehicleSummary().Tables[0].Rows)
            {
                Summary summary = new Summary();
                summary.Value = dr[1].ToString().Trim();
                summary.Item = Convert.ToInt32(dr[2]);
                lstSummary.Add(summary);

            }
            return Json(lstSummary.ToList(), JsonRequestBehavior.AllowGet);
        }
8. Now add view.
9. Add .js files 

10. Add Code to view


    

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script src="http://code.highcharts.com/highcharts.js"></script>
    <script src="http://code.highcharts.com/modules/exporting.js"></script> 
    
    
       
</head>
<body>
    
    <script type="text/javascript">

        $(function () {
            $.ajax({
                url: '/HighCharts/VehicleSummary',
                dataType: "json",
                type: "GET",
                contentType: 'application/json; charset=utf-8',
                async: false,
                processData: false,
                cache: false,
                delay: 15,
                success: function (data) {
                    // alert(data);
                    var series = new Array();
                    for (var i in data) {
                        var serie = new Array(data[i].Value, data[i].Item);
                        series.push(serie);
                    }
                    DrawPieChart(series);
                },
                error: function (xhr) {
                    alert('error');
                }
            });
        });
        function DrawPieChart(series) {
            $('#container').highcharts({

                chart: {
                    plotBackgroundColor: null,
                    plotBorderWidth: 1, //null,
                    plotShadow: false
                },
                title: {
                    text: ' Vehicle Summary'
                },
                tooltip: {
                    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: false
                        },
                        showInLegend: true
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'Task Status',
                    data: series
                }]
            });
        }
    </script>
    <div id="container" style="min-width: 350px; height: 350px; max-width: 600px; margin: 0 auto"></div>
</body>
</html>


12. Now run the project.


Elmah (Error Logging)

1. Open visual studio
2. Create a new project.
3. Right Click solution and select Manage Nuget Packages
4. Search Elmah and add the elmah package.




                                                                                                                                                            

6. Click Install to install Elmah.                                                                                                               7. Now run application and check for the 404 Error.                                                                                                    



  8. You can see error log by entering URL http://localhost:56571/Elmah.axd

Sunday, 22 January 2017

Creating SQL Server Database Project

1. Open Visual Studio
2. Create a new project and select SQL Server and select "SQL Server Database Project".



3. Right Click Solution and select Schema Compare.




4. Select the Source and Destination Database.




5. Click compare. and see the changes between the source and destination database.

6. Click update to update the destination database. you will see the generated .sql files in the project dbo folder.
7. If you want to load data with that .sql files then right-click the Solution Explorer and click publish.
8. You can also import Database and .sql script to project.
9. Right-click solution and click publish export .sql script to database.

Friday, 30 December 2016

Create Asp.net MVC Demo Application using Entity Framework

1. Open Visual Studio
2. Create a New Project
3. Select Asp.net Web Application and select MVC template



4. Create Database
5. Install Entity Framework using "Manage Nuget Packages".
6. Right Click the project and add "ADO.Net Entity Data Model"
















7. Add a new Controller to the Controller Folder named EmployeeController.








8. Change RouteConfig.cs accordingly and run the project.

Thursday, 7 April 2016

C interview questions

1. Is C Object-Oriented Language?
Ans. No, C is a Procedural Language.

2. What are the storage classes in C?
Ans. auto, register, static, extern

3. Who is the father of the C language?
Ans Dennis Ritchie

4. What are the data types supported by the C language?
Ans. char, int, float, double

5. What is the variable?
Ans. Variable is used to store data for later use.

6. What is constant in C?
Ans. Constant is like variable except for its value never changed during the execution of the program.

7. What are the keywords in C?
Ans. Keywords have a specific meaning in C and it can not be used as a variable name.

8. What are the C operators?
Ans C operators are used to perform mathematical operations.

9. List Operators in C.
Ans. +, -, *, /, %

10. What is the NULL pointer in C?
Ans. The pointer that doesn't refer to any address of value but NULL is known as a NULL pointer.

11. How many types of loops are used therein C?

Ans. While loop
         For loop
         Do-While loop
         Nested loop

12. What is Void?
Ans. Void is the datatype that has no value.


Thursday, 18 February 2016

Java Interview questions


1. What is Java?

Ans. Java is an object-oriented programming language. It is a platform independent language.

2. Which is the most important feature of java?

Ans. Java is a platform independent language.

3. Who is the father of the Java programming language?

Ans. James Gosling.

4. What are the supported platforms by java programming language?

Ans. Java runs on Windows, Mac OS, Linux/Unix.

5. What are the data types supported by java?

Ans. byte, short, int, long, char, float, double.

6. What is JVM?

Ans, JVM is a Java Virtual Machine which is a run time environment for the compiled java classes.

7. Is java pure object oriented language?

Ans. No.

8. What is constructor?

Ans. The constructor is just like method and invoked at the time of object creation.

9. Can we make a constructor final?

Ans. No

10. Is constructor inherited?

Ans. No

Tuesday, 10 November 2015

SharePoint Interview Questions

1. What is Microsoft SharePoint?
Ans. Microsoft SharePoint is a browser-based collaboration and document management platform. It allows groups to set up a centralized, password-protected space for document sharing.

2. What are web parts?
Ans. WebParts are packages that can be dropped on the sharepoint web part page.

3. Who is the father of Microsoft SharePoint?

Ans. Jeff Teper

4. What is CAML?

Ans. CAML stands for Collaborative Application Markup Language. It is XML based markup language that is used in Microsoft Sharepoint.

5. What are the zones in SharePoint?

Ans. Zones provide separate authentication for the same web application.

6. How many zones we can create for each web application?

Ans. we can create 5 zones for each web application.
         1. Default
         2. Intranet
         3. Extranet
         4. Internet
         5. Custom

7. What is DWP?
Ans. It is a web part file extension.

8. What is the central administration?

Ans. This is a site used by admins to manage and configure settings.

9. What is SharePoint Theme?
Ans. It contains files which defines look and feel of content pages in SharePoint.

10. What is custom action?

Ans. It represents link, toolbar button,menu item o any control that can be added to the toolbar or                menu that appears in the UI.

11. What are the type of input forms that can be created for the WorkFlow in SharePoint?
Ans. We can create different type of input forms like
         An association form
         An initiation form
         A modification form
         A task edit form

12. How to create an instance of the list?
Ans. We can create instance of the list by creating an instance XML file.

SQL server tricky questions