Saturday 19 September 2015

Method Overloading And Method OverRiding

Method Overloading refers to Concept the defining the one or more functions or methods with same name with different Parameter Length or Parameter Types . So Functions are differenciated by their signature or Parameters .

Example For Method OverLoading

//Overloading
public class test
{
    public void getStuff(int id)
    {}
    public void getStuff(string name)
    {}
}
 
Method OverRiding is Totally Different Concept As Compared to Method Overloading . Method OverRiding Refers to Redefining the Function that Correspond to Some Other Class and Accessed Using Inheritance .

The Concept of Method OverRiding depends on Two Keywords - Virtual and OverRide

In Simple Scenario to Explain Method OverRiding with Example is Lets Assume We have a Base Class with function Sample() in Base Class then The Oher class that Derived From that Base Class Can Redefine the Functionality of That Sample() Function refers to Concept of Method OverRiding .

Example1  For Method OverRiding

class BC
{
  public virtual void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  public override void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class Demo
{
  public static void Main()
  {
     BC b;
     b = new BC();
     b.Display();    

     b = new DC();
     b.Display();    
  }
}

Output

BC::Display
DC::Display
 

Example1  For Method OverRiding

//Overriding
public class test
{
        public virtual getStuff(int id)
        {
            //Get stuff default location
        }
}

public class test2 : test
{
        public override getStuff(int id)
        {
            //base.getStuff(id);
            //or - Get stuff new location
        }
}

 

 

Value Types Vs Reference Types Dotnet


Stack and heap

In order to understand stack and heap, let’s understand what actually happens in the below code internally.

public void Method1()
{
    // Line 1
    int i=4;

    // Line 2
    int y=2;

    //Line 3
    class1 cls1 = new class1();
}


It’s a three line code, let’s understand line by line how things execute internally.
  • Line 1: When this line is executed, the compiler allocates a small amount of memory in the stack. The stack is responsible for keeping track of the running memory needed in your application.
  • Line 2: Now the execution moves to the next step. As the name says stack, it stacks this memory allocation on top of the first memory allocation. You can think about stack as a series of compartments or boxes put on top of each other.
  • Memory allocation and de-allocation is done using LIFO (Last In First Out) logic. In other words memory is allocated and de-allocated at only one end of the memory, i.e., top of the stack.
  • Line 3: In line 3, we have created an object. When this line is executed it creates a pointer on the stack and the actual object is stored in a different type of memory location called ‘Heap’. ‘Heap’ does not track running memory, it’s just a pile of objects which can be reached at any moment of time. Heap is used for dynamic memory allocation.

Why String Are Value Types Csharp Dotnet


The distinction between reference types and value types are basically a performance tradeoff in the design of the language. Reference types have some overhead on construction and destruction and garbage collection, because they are created on the heap. Value types on the other hand have overhead on method calls , because the whole object is copied rather than just a pointer.

Because strings can be  much larger than the size of a pointer, they are designed as reference types. Also, as Servy pointed out, the size of a value type must be known at compile time, which is not always the case for strings.

Strings aren't value types since they can be huge, and need to be stored on the heap. Value types are stored on the stack. Stack allocating strings would break all sorts of things: the stack is only 1MB, you'd have to box each string, incurring a copy penalty, you couldn't intern strings, and memory usage would balloon, etc

That is why a string is really immutable because when you change it even if it is of the same size the compiler doesn't know that and has to allocate a new array and assign characters to the positions in the array. It makes sense if you think of strings as a way that languages protect you from having to allocate memory on the fly 

Boxing And Unboxing in DotNet

Boxing and unboxing

I Recommend to Go to this link to Read about Value Types and Reference Types Before Going To Understand the concept of Boxing and Unboxing

Value Types Vs Reference Types Dotnet
http://geeksprogrammings.blogspot.in/2015/09/value-types-vs-reference-types-dotnet.html

Boxing and unboxing are the most important concepts you always get asked in your interviews. Actually, it's really easy to understand, and simply refers to the allocation of a value type (e.g. int, char, etc.) on the heap rather than the stack.

Boxing

Implicit conversion of a value type (int, char etc.) to a reference type (object), is known as Boxing. In boxing process, a value type is being allocated on the heap rather than the stack.

Unboxing

Explicit conversion of same reference type (which is being created by boxing process); back to a value type is known as unboxing. In unboxing process, boxed value type is unboxed from the heap and assigned to a value type which is being allocated on the stack.

For Example
    // int (value type) is created on the Stack
    int stackVar = 12;
    
    // Boxing = int is created on the Heap (reference type)
    object boxedVar = stackVar;
    
    // Unboxing = boxed int is unboxed from the heap and assigned to an int stack variable
    int unBoxed = (int)boxedVar;


Real Life Example

    int Val_Var = 10;
    ArrayList arrlist = new ArrayList();
    
    //ArrayList contains object type value
    //So, int i is being created on heap
    arrlist.Add(Val_Var); // Boxing occurs automatically Because we are Converting int to Object Type This is Called Boxing
    
    int j = (int)arrlist[0]; // Unboxing occurs

Performance implication of boxing and unboxing

In order to see how the performance is impacted, we ran the below two functions 10,000 times. One function has boxing and the other function is simple. We used a stop watch object to monitor the time taken.
The boxing function was executed in 3542 ms while without boxing, the code was executed in 2477 ms. In other words try to avoid boxing and unboxing. In a project where you need boxing and unboxing, use it when it’s absolutely necessary.

Boxing And Unboxing in DotNet
Boxing And Unboxing in DotNet 



 

 

Thursday 20 August 2015

Difference Between Stored Procedure and Functions Sql

Stored Procedure and Functions

 

1. Function Must Return Value

   For Stored Procedure it's Not Must to return value it's optional 

2. Stored Procedures are pre-compile objects which are compiled for 
first time and its compiled format is saved which executes (compiled code) whenever it is called 

But Function is compiled and executed every time when it is called

3. Function can Accept only Input Parameters
   But Stored Procedure Can Accept Both Input and Output Parameters

4. Functions can be called from Procedure whereas Procedures cannot be called from Function

5. Functions Like Views only Accept Data Select Statements It does not Allow the Permanent Storage of data so it does not allows DML statements like Insert , Update , Delete

Whereas Store Procedure Allows All type of DML statements like Insert , Update and also Select Statements.

6. Funtions can be used in Select Statements like views to View data 
But Stored Procedure Cannot be Embedded in Select Statements

7.
 

Difference Between Views And StoredProcedure Sql

Stored Procedure Vs Views


1. Stored Procedure are collection of pre-executed sql Statements that accepts parameters as input and depending on input parameters passed gives the Output Result

Views Act like Virtual Tables That Contains set of Rows and Columns from multiple original table of Database according to defined Query Commands

2. Stored Procedure Cannot be Used as Large Building Block or we can simply say It cannot be treated as tables in large queries 

But Views Can be treated like tables we can Use Views similar to table and execute select statements on Views Similar to Tables

3. Stored Procedures Allow the Use of Data Manipulation Command like Insert Data , Update data on Table or Schemas To Manipulate Data

But Views Cannot have Data Manipulation Command It can only give list of data or View of data based on set of Queries in it . Views cannot be used to Permanently store data in database it allows just to view the data.

4. Views  can have  only one Select Statement Allowed To Use

Store Procedure Can Use Various Set of Statements That also Include If-Else Statements

5. View is a virtual table that only exists when you use the view in a query. Its considered virtual table because it acts like a table, and the same operations that can be performed on a table can be performed on a view. Virtual table doesn't stay in the database, it gets created when we use the view and then delete it. 

But Stored Procedure Physically Exist 

6. Views are Used for Providing Security to data So that by using the Views we can View only Particular view of the schema to the user Not the Full View with required columns. Their is no physical presence of view data anywhere in database.

Stored Procedure allows to perform any type of data Manipulation operation But We can also Put Security Permission on Store Procedure In order to Restrict its Access From Unauthorized User


7. Code Sample For Stored Procedure and Views
/*
This Stored procedure is used to Insert value into the table tbl_students. 
*/

Create Procedure InsertStudentrecord
(
 @StudentFirstName Varchar(200),
 @StudentLastName  Varchar(200),
 @StudentEmail     Varchar(50)
) 
As
 Begin
   Insert into tbl_Students (Firstname, lastname, Email)
   Values(@StudentFirstName, @StudentLastName,@StudentEmail)
 End
 
 
/*
View Example
*/
CREATE VIEW [Category Sales For 1997] AS

SELECT DISTINCT CategoryName,Sum(ProductSales) AS CategorySales

FROM [Product Sales for 1997]

GROUP BY CategoryName 

Saturday 1 August 2015

Jquery Full Calender Integrated With ASP.NET


Jquery Full Calender Integrated With ASP.NET


- First you need to define the function in Code-Behind using c# or vb.net that will make a Class that contains the similar properties that is required by Jquery full calendar to Fill the Calendar

- Then We Use Jquery Ajax and make request to that function that will pass some data that you can fill manually or you can also fetch that from database and then return that to this Ajax Request

- Now use the Code below to Plot then on Full Calendar

If you have any problem setting this please tell me in comments I am here to help you setting this up

Download Full Solution Code Here . Don't Forget to Share Us on Social Media

Code To Fetch Events Using Jquery


 <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: "application/json",
                data: "{}",
                url: "Default.aspx/GetEvents",
                dataType: "json",
                success: function (data) {
                    $('div[id*=fullcal]').fullCalendar({

                      
                        header: {
                            left: 'prev,next today',
                            center: 'title',
                            right: 'month,agendaWeek,agendaDay'
                        },
                        editable: true,
                        events: $.map(data.d, function (item, i) {
                            var event = new Object();
                            event.id = item.EventID;
                            event.start = new Date(item.StartDate);
                            event.end = new Date(item.EndDate);
                            event.title = item.EventName;
                            event.url = item.Url;
                            event.ImageType = item.ImageType;
                            return event;
                        }), eventRender: function (event, eventElement) {
                            if (event.ImageType) {
                                if (eventElement.find('span.fc-event-time').length) {
                                    eventElement.find('span.fc-event-time')

.before($(GetImage(event.ImageType)));
                                } else {
                                    eventElement.find('span.fc-event-title')

.before($(GetImage(event.ImageType)));
                                }
                            }
                        },
                        loading: function (bool) {
                            if (bool) $('#loading').show();
                            else $('#loading').hide();
                        }
                    });
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    debugger;
                }
            });
            $('#loading').hide();
            $('div[id*=fullcal]').show();
        });
        function GetImage(type) {
            if (type == 0) {
                return "<br/><img src = 'Styles/Images/attendance.png' style=

'width:24px;
height:24px'/><br/>";
            }
            else if (type == 1) {
                return "<br/><img src = 'Styles/Images/not_available.png' style=

'width:24px;
height:24px'/><br/>";
            }
            else
                return "<br/><img src = 'Styles/Images/not_available.png' style=

'width:24px;
height:24px'/><br/>";
        }

    </script>


Web Method In C# that Pass the Event to Jquery Ajax Request


  [WebMethod]
        public static IList GetEvents()
        {
            IList events = new List<Event>();
            for (int i = 0; i < DateTime.DaysInMonth(DateTime.Now.Year, 


DateTime.Now.Month); i++)

            {
                events.Add(new Event
                {
                    EventName = "My Event " + i.ToString(),
                    StartDate = DateTime.Now.AddDays(i).ToString("MM/dd/yyyy"),
                    EndDate = DateTime.Now.AddDays(i+1).ToString("MM/dd/yyyy"),
                    ImageType = i % 2,
                    Url = @"http://www.google.com"
                });
            }
            return events;
        }

Class To Define the Event


 public class Event
    {
        public Guid EventID { get { return new Guid(); } }
        public string EventName { get; set; }
        public string StartDate { get; set; }
        public string EndDate { get; set; }
        public int ImageType { get; set; }
        public string Url { get; set; }
    }

Friday 1 May 2015

Using Report Viewer with Dataset Asp.net Csharp and vb



For Using Report Viewer in Asp.net or Desktop Application using Csharp or Visual basic I am today providing a simple step by step solution -

Demo File is also available to Download so that you can have a demo for how to use or Use Reports With Dataset in Asp.net . I have provided Both Csharp and Vb code

Step 1 - First of Start a C# Project or Vb Project and then Add an Empty Webform to it .




Step 2 :- Now Right Click on Solution in Solution Explorer and Click on Add then click on New Item . Then Click On DataSet and Give a Name and Click Ok . This will add a Dataset in your Project . I will recommend it give dataset a name similar to database table whose data you want to show in Report Viewer

Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet
Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet


Step 3 :- Now After Dataset is added Right Click on Dataset Page and Click on Add then click on DataTable It will add a DataTable

Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet
Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet


Step 4:- Now Add Columns to DataTable and Must Ensure that the name of these DataTable column must be same to Names of Columns in Database that Corresponds to this DataTable

Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet
Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet

Step 5 :- Now Again Right click on solution in Solution Explorer and Click on Add then click on New and then click on Report give it a name and click on ok . This will add a Report to your Project

Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet
Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet

Step 6 :- Now From You Controls Toolbox in Visual Studio . Place a Report Viewer Control on your WebPage as shown in image below


Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet
Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet


 Step 7 :- Now Open your Recently Added Report file you will see it same as shown below


Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet
Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet


Step 8 :- Now we need to Add the Previously added dataset or need to link the dataset we added in previous steps to the report file

Step 9 :- So for that linking Right Click on Dataaset folder in sidebar of Report Then Click on Add Dataset then you will see the following screen

Step 10 :- Now select the Added Dataset from Combox for DataSource and then after that Choose the DataTable from Next Last Combobox


Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet
Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet

Step 11  :- Now Dataset Fields will be added Under Dataset folder in Left Sidebar of Report . Now you can Drag drop fields from Left Sidebar and also Place the Textbox for Labelling like I have added for ID,Name and heading etc



Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet
Using Report Viewer with Dataset Asp.net Csharp and vb , Using Reporting in asp .net dotnet

Step 13:-  Now we need to Add the Code so Open Cshar Code side of Webpage where you have added the Report viewer control And Add the following code according to your choose language c# or vb

Now At Page_Load Event of your WebPage Add the Following Code According to C# or VB


Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WebForms

        'VB CODE
        ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local
        ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc")

        Dim dsUsersInfo As New DataSet1
        Dim con As New SqlConnection("Your Connection String")
        Dim cmd As New SqlCommand("select * from YourTableName", con)
        Dim da As New SqlDataAdapter()
        da.SelectCommand = cmd

        'DataTable1 is the DataTable we have created in Dataset1 that contains our columns
        da.Fill(dsUsersInfo, "DataTable1")


        Dim datasource As New ReportDataSource("DataSet1", dsUsersInfo)
        ReportViewer1.LocalReport.DataSources.Clear()
        ReportViewer1.LocalReport.DataSources.Add(datasource)


        'CSharp Code
        'ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local
        'ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc")

        ' DataSet1 dsUsersInfo = new DataSet1();

        '        SqlConnection con = new SqlConnection("Your Connection String"));

        '            con.Open();
        '            SqlCommand cmd1 = new SqlCommand("select * from TableName", con);

        '            SqlDataAdapter da = new SqlDataAdapter(cmd1);
        '            da.Fill(dsUsersInfo, "DataTable1");
        '            con.Close();

        '        ReportDataSource datasource = new ReportDataSource("DataSet1", dsUsersInfo.Tables[0]);

        'ReportViewer1.LocalReport.DataSources.Clear()
        'ReportViewer1.LocalReport.DataSources.Add(datasource)




Step 12 :- Now when you run the Page where you have added the Report viewer control It will show the Report with data from database


Parse Error The base class includes the field ‘reportViewer’, but its type (Microsoft.Reporting.WebForms.ReportViewer) is not compatible with the type of control (Microsoft.Reporting.WebForms



Parse Error Message:the base class include the field 'reportviewer1',but its type (Microsoft.reporting.webforms.reportviewer) is not compatible with the type of control (Microsoft.reporting.webforms.reportviewer)

This Error Occur due to Usage of different version of ReportViewer in Same .Net Project . It may happen when you have referenced a different version of ReportViewer dll files as compared to Version of Report Viewer dll ReportViewer Control is using and referenced in web.config file

So we need have same version of Report Viewer dll file in web.config file that matches with Control using and as well as version that we have referenced .

So Dll File we are using is - Microsoft.Reporting.WebForms .

Fix For This Error - 


Go to your web.config file and Search for following code -

    <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>

YOU CAN SEE VERSION IN ABOVE CODE "VERSION=10.0.0.0" OR IT MAY BE 11.0.0.0 OR BELOW 10 .SO WE NEED TO MAKE REFERENCE TO SAME ASSEMBLY IN ORDER TO MATCH THE VERSION OF ASSEMBLY REFERENCED WITH CONTROL USING ASSEBLY
SO HERE CONTROL IS USING 10.0.0.0 VERSION OF ASSEMBLY

STEP FOR FIX Parse Error 

1. Right Click on your Website or WebApplication in Solution Explorer
2. Then Click on Add Reference 
3. Then Search For Reporting
4. Then Checkmark the Checkbox for Microsoft.ReportViewer.WebForms with Same Version  10.0.0.0 or other that is available in your web.config
5. Now Click ok 
6. Rebuild Your Solution and Now Error Should be Resolved

If Any Problem Exist Still then Feel Free to Put your Query In Comment Here .

Thursday 30 April 2015

Bootstrap dropdown menu not working


Today Twitter Bootstrap has become a basic need of the Website Development . Today i am giving some explanation regarding a common mistake while using Twitter Bootstrap . This mistake will happen only when you are trying to create a Navigation Bar for your website / webapplication using Bootstrap NavBar .

So , In order to create a NavBar we must require 3 files -

1. Bootstrap.css file
2. Jquery.js file
3. Bootstrap.js file

So Bootstrap.css file is used for Design and look of Navbar and Now the most important thing due to this you may suffer from an error -

Bootstrap dropdown menu not working 

So , Ever you suffer from this a simple solution is you must first include the jquery.js file or any version of jquery.js file as you wish as shown in example below and then after jquery file you can include bootstrap.js file 

If it still does not work just include the following script code after including the above two js files

<script>
    $(document).ready(function () {
        $('.dropdown-toggle').dropdown();
    });
</script>

A Simple Example of Twitter Bootstrap Navbar is Below :-



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="css/bootstrap.css" rel="stylesheet" />
    <link href="css/bootstrap.min.css" rel="stylesheet" />


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script>
    $(document).ready(function () {
        $('.dropdown-toggle').dropdown();
    });
</script>




   
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>

       
         <nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Manage Users <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu4">
  <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Regular link</a></li>
  <li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Disabled link</a></li>
  <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another link</a></li>
</ul>
        </li>
      </ul>
    <div class="btn-group">
  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
    Action <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu">
    <li><a href="#">Action</a></li>
    <li><a href="#">Another action</a></li>
    <li><a href="#">Something else here</a></li>
    <li class="divider"></li>
    <li><a href="#">Separated link</a></li>
  </ul>
</div>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a></li>
     
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>


    </div>
    </form>
</body>
</html>

Tuesday 28 April 2015

ASP.NET MVC Action Return View Not Changing URL

The return View(.......) in Action of Controller is the statement that we use to return the view View for a Particular Controller Request . But Return view will return the view exactly you want and render the view but it will not change or target the user to target url  . The simple solution is below -


Code For an Action -

[HttpPost]
public ActionResult Start(SomeViewModel someViewModel)
{
  ...
  return RedirectToAction("SomeOtherAction");

              
                             or


  return RedirectToAction("Action Name", "Controller Name");
}

So , In code above We are using RedirectToAction instead of using  return view this can be used in total of 6 variants .

I have give 2 of simple one . In Parameter to these actions you need to pass the controller and action name according to variant you choose


Sunday 22 March 2015

The cockroach theory for self development - The Persuit Of Happyness


At a restaurant, a cockroach suddenly flew from somewhere and sat on a lady. She started screaming out of fear. With a panic stricken face and trembling voice,she started jumping, with both her hands desperately trying to get rid of the cockroach. Her reaction was contagious, as everyone in her group also got panicky. The lady finally managed to push the cockroach away but ...it landed on another lady in the group.

Now, it was the turn of the other lady in the group to continue the drama. The waiter rushed forward to their rescue. In the relay of throwing, the cockroach next fell upon the waiter. The waiter stood firm, composed himself and observed the behavior of the cockroach on his shirt. When he was confident enough, he grabbed it with his fingers and threw it out of the restaurant.

Sipping my coffee and watching the amusement, the antenna of my mind picked up a few thoughts and started wondering, was the cockroach responsible for their histrionic behavior?
If so, then why was the waiter not disturbed? He handled it near to perfection, without any chaos. It is not the cockroach, but the inability of the ladies to handle the disturbance caused by the cockroach that disturbed the ladies.

I realized that, it is not the shouting of my father or my boss or my wife that disturbs me, but it's my inability to handle the disturbances caused by their shouting that disturbs me. It's not the traffic jams on the road that disturbs me, but my inability to handle the disturbance caused by the traffic jam that disturbs me. More than the problem, it's my reaction to the problem that creates chaos in my life.

Lessons learnt from the story: I understood, I should not react in life. I should always respond. The women reacted, whereas the waiter responded. Reactions are always instinctive whereas responses are always well thought of. A beautiful way to understand............LIFE.
Person who is HAPPY is not because Everything is RIGHT in his Life.. He is HAPPY because his Attitude towards Everything in his Life is Right..!!,,,,,,,
Really beautiful