Quotes .....

There never was, there never will be, a man who is always praised, or a man who is always blamed....

Sunday, December 30, 2012

31st of December 2012


It has become an habit for me to post a new article on my blog on the 31st December every year. Lets think about how to organizing the year 2013 - the New year resolution .

Making new year resolution is good while stick to it throughout the year is the best. I am not the first person to admit it and I don't expect anyone to achieve it hundred percent the way one imagined at jotting down the list on 1st of January.

It is about managing your time worthy and in a productive way. It is also about the feeling you get in the 31st December about yourself. If you are feeling like someone who wasted 365 days or 8760 hours or 525600 seconds from your life, then obviously it's time to save the rest of your precious time ahead since you have already wasted an year.

Remember you are full of energy to achieve what ever you decided. 

Adios 2012!

Sunday, September 23, 2012

Mentoring Effectively


I had the opportunity to follow an a e-learning course on the topic "Mentoring Effectively", below is an extraction from it.

Mentoring Effectively


Where did the word “mentor” come from? In Homer’s epic poem “Odyssey,” Mentor looked after
Telemachus, the son of Odysseus, while Odysseus was away. Mentor has since come to mean a
wise and trusted guide or teacher

Today many people have earned the title “mentor” by acting as wise and trusted guides or teachers
to less experienced colleagues in their organizations or professions. Mentoring may be an ancient
idea, but it’s becoming more and more vital to career development. Although being a mentor
requires a substantial investment of your time and effort, it also has many rewards.

Proteges gain most of the benefits in mentoring relationships.”- This is false. Benefit
everyone involved, including mentors, protégés and their organizations.

Aspects of effective mentoring- Why it’s important, the various roles of mentors, how to use
effective communication skills in mentoring relationships, how to manage the mentoring relationship.

The Importance of Mentoring
Have you ever guided someone through unfamiliar terrain? Did you think about how important your
guidance was in that situation?

Career development is one of the most significant issues facing organizations today. Many
companies are looking to mentoring programs to help develop their employees. A mentor provides
guidance at crucial times in a protégé’s career. Whether a mentor is inducting a new recruit or
grooming a rising star for an executive position, the mentoring relationship has great importance.

Although mentoring relationships are as varied as the situations that produce them, they all are
designed to propel professional development to new heights at greater speeds.

Thursday, August 9, 2012

LoadFile() Method of the object AxAcroPDFLib.AxAcroPDF can't use to load already open PDF files

The Question:

I have made a Windows desktop application(in C#) where I use the AxAcroPDF control to display a pdf-file on a form when user give the path of the pdf and click a button. Pdf-file is located in one network shared file folder where multiple users can access it.
(I use the LoadFile() Method of the object AxAcroPDFLib.AxAcroPDF)

This is working fine. But when the same pdf file which my applications try to open is already opened using Adobe Reader then my application can’t open the same pdf file.

If the PC my application installed has Adobe reader 7 then application throw the error message as "System.ApplicationException Failed Loading PDF Template" and application freeze.

And if the application running PC’s having Adobe Reader X installed then no error will appear but the loading screen appears for ever.

But opening the same pdf simultaneously in two or more PC using my application works perfect.


The Answer:

Solution01 - Not recommended (this sometimes not work)

After desperate search on forums I couldn't find a proper solution as I was expecting to find. But to avoid the program get crash, I put a check before loading the pdf.

bool PDFAvailable = axAcroPDF1.LoadFile(PDFPath.ToString());

If the Boolean variable 'PDFAvailable' return true I'll load the PDF like below. Else a proper message is thrown.
bool PDFAvailable = axAcroPDF1.LoadFile(PDFPath.ToString());                                                if (PDFAvailable == true)                        {                            axAcroPDF1.LoadFile(PDFPath.ToString());                            axAcroPDF1.setShowToolbar(false); //disable pdf toolbar.                            axAcroPDF1.Enabled = true;                                                    }                        else                        {                            MessageBox.Show("Selected PDF Template Is Locked By Another Application.", ""Test Application"", MessageBoxButtons.OK, MessageBoxIcon.Information);                                                    }
Solution02 - Recommended (Work fine for Adobe Acrobat Reader X)

I found a workaround in this
post
Rather than LoadFile() we can use the "src" property of the control.
The drawback is Adobe acrobat Reader 7 doesn't support src property.

Solution03 - Recommended for any version

Copy the pdf file to client PC temp folder and then read :-)

Saturday, June 9, 2012

Commonwealth Short Story Competition 2012

The Start.

By Surangi Tissera

This is the winter season for Europe. Working hours changed Preshantha is in a really bad mood. According to the new schedule she has to work from one thirty to ten thirty in the evening. Previously she could start the work an hour earlier and leave at nine thirty, which is an hour earlier than now.

This is Preshantha’s first paid job. Just after her secondary education, she joined “Rise International” as a Data Analysis. The company is an UK (United Kingdom) based pioneers in outsourcing field and also the first of its kind to choose Sri Lanka as one prospective location to open a branch office. Preshantha was lucky enough to be chosen as a “Real Time Worker” which provides more and more benefits comparative to general employees of the company.

A “Real Time Work” means work according to the Europe working hours. This requires starting the work at odd times to cope up with the five and a half hour to six and a half hours time gap between Europe continent and Asia continent. And also it requires working in odd days like local holidays as well and having leaves in odd days like holidays in Europe countries. At first, it was the most extraordinary experience for her and her family. All by her at ten o’clock at night outside home was the most horrible thing she could imagine at the time. Even her elder brother is supposed to be back at home before nine o’clock in the night. This is due to the fact that most of the government and private offices are closed down around six o’clock in the evening. And public transports were hard to find after nine o’clock in the night.

But now the excitement period is over for her. This is her second year after getting the permanent employment with the company. Now a day it’s only the counting hours to get off for the day and days for the next salary is all that matter to her. But she couldn’t figure out what is the cause for her present uneasiness or unhappiness. Could it be the Aruna’s marriage? Could it be Rohan’s promotion or something else? She started dipping to the most depth of her feelings in the heart.

Aruna, Preshantha and Rohan comprised the “Trio” group as it is known to everyone in the Rise. There are few other groups except Trio which are having interesting names like “Spice” also from Sri Lanka, “Duel Ducks” from Germany and “Xmen” from America. Most of the other groups have only the boring names documented at origin like D10.1 or CIX which were the official identification given to the groups at the beginning of those projects.

The Trio group which comprises of two female employees and a male employee is one of the oldest and the most successful project carrying out by the Rise International. Trio always kept this same blend of two females and a male from the day it was first initiated, although original team members had left the Trio group.

When Preshantha was joining to Trio, both Rohan and Aruna were there. When consider their ages Aruna is the eldest where Preshantha is the youngest. When time slowly passes, three of them became the best friends. They are belonging to three different religions and it was always an interesting combination. They together spend most of their free times at work and even each others religious festivals they get together and celebrated. Although their friendship gets flourished, at the same time they get isolated from fellow members at the Rise International. This is the very reason why Preshantha has to spend an unhappy isolated times at office now.

It was the Aruna’s wedding that the first change Trio experienced. It was a proposal from Aruna’s relatives in India. As a result, after the marriage Aruna had to leave from Sri Lanka to go to India where her husband lives. But the Trio operated as usual with Preshantha and Rohan are working in the Rise International’s Sri Lankan branch and Aruna is working in the Rise International’s Indian branch.

Gradually two of them learned to pass the time without Aruna in physically with them. Through e-mails and phone calls they continued their friendship. It didn’t take so long to start rumors about Preshantha and Rohan. Also two of them felt very bad about the situation and gradually tried to minimize the time they spend together.

Rohan started playing Badminton, which gave him the opportunity to make new contacts and evade from Preshantha most of the time. Preshantha started to study for a Computer Diploma just for the sake of doing something to pass the time. At first she wanted to move from the Trio group. But Ms. Silva, who was the projects manager, didn’t allow her as the Trio group performance was excellence and if Preshantha leaves suddenly it takes sometime to find another suitable person to the vacating post and to train that person. On the other hand there were no new project openings for Preshantha to join in.

Another two months passed with this same routing until one day after a management meeting came the news of Ms. Silva‘s promotion as Assistance Service delivery Manager in Asia Operation.

The vacating position of the Project Manager became the main aim of Preshantha. She got new hopes to do daily works. She knew she has the most qualifications among all of others. She was glad to think that all the others including Rohan are going to work under her.

Sometimes she thought why she became so angry with Rohan, who was once a good friend of her. Is it sheer jealousy or anything else? She felt the need to take revenge from him by hurting him so badly. She thought it’s very unfair of her to remain isolated while Rohan is having all the people around him after they started to walk in different routes.

Of course as always Aruna was a good friend to them and the Aruna’s e-mails and phone calls were the only things Rohan and Preshantha shared together in those days.

Her hope doesn’t last for weeks when the announcement came of Rohan’s promotion as the Project Manager. Only sensible thing Preshantha could do at that time was to congratulate him for his achievement. To Preshantha this new Promotion signaled the Rohan’s winning from the cold war two of them had.

For the first time in Trio’s history it comprised with three females. The newly joined girl was a fresher from high school and needed to go through a rigorous training in order to do her job properly. All in all it is really a tough time for Preshantha as she has to look into the newly joined Trio member’s training and together with Aruna had to cover most of the daily works in the Trio group. But the most intolerable thing for Preshantha is to report working progress to the new Project Manager – Rohan who is now called as Mr. Peris.

She thought Rohan is laughing to her at every time she saw him. Therefore tried to evade from him as much as possible which most of the time doesn’t work at all. There was thousand of other information he needed to request from her or discuss with her about the ongoing projects. At some point she thought he is trying to steal her innovative ideas and use them as if they were his own. Or may be he is trying to find a fault of her so he may come up with a good scheme of punishing her and ultimately sacking her from her current job.

She has taken all her available official leave for the present year. Today is one of the worst days for her as she has to hand over a leave application form to Mr. Peris’s approval. She had to struggle with herself over the idea of walking up to Rohan’s new seat. She felt sad about herself because she couldn’t help her out of this shameful situation.

A plot started to work in her mind. That is if he speaks a word about her works or her overly taken leaves to resign from her current position at once. At the same time she knew it’s a difficult thing to find so quickly a new job which will provide her present salary and benefits. She can remember the time she spent before getting the present job. Looking for jobs in the news papers, writing applications and facing desperate interviews which turn out to be she is lacking experience, qualification or she is having everything more than interviewing panel expected. She wondered whether she will have to stay long in unemployment, struggling to find a job or with her current experience she will be able to land in a much better job than her current position.

She was in this day dreaming when she heard a familiar call of her name.

Preshantha what are you doing at this hour of the night? It’s nearly 11 O’clock now.” Rohan was walking toward Preshantha’s seat.

She got out of her dream only to find empty seats around her which symbolize that all of the other Real Time Workers have taken off for the day. She is not scared at all because she knew there are people working around the clock in other sections of the office. But Preshantha felt glad to speak with Rohan all along. She hasn’t spoken with him along during the last eight months as they were evading all the possible casual meetings. She thought she saw the familiar friendly smile of Rohan’s which always in his face and which most of the time she thought was a mocking remark. But she doesn’t want to show any of her feelings now. So she hardens her facial muscles and manages to pose back the same question to him.

What are you doing Rohan? Oh! I forgot, Mr. Peris. You must be busy with those reports preparation I guess.”

She is not expecting an answer and is not looking at him at all. She is getting ready to take off.

All of a sudden she could feel a hand touching hers. She tried to get rid of it but couldn’t. In a second she could hear his caring voice.

Preshantha let’s stop this. Aren’t we good friends?” In silence she listened to him without giving any sign to his talking.

I was looking at you all this hour when others gone. I have good news for you Preshantha, with a bad news too”.

Preshantha looked at him and saw his dark clouded face. He kept speaking while looking at an e-mail on his other hand.

How handsome and good looking he is she thought to herself. She has never admired or looked at him or anybody in this manner. But she thought why she couldn’t notice it before.

You are given a year scholarship to our head office in England to work and learn as a team leader to our new project going to be launch at the end of next year. This is officially to be informed to you on tomorrow. I was waiting for this message.”

Could he be joking? She thought. Preshantha knew she shouldn’t trust him. So let it be officially informed to her why he should worry about this. But Preshantha needs to quench her curiosity.

And the bad news is ….” She asks.

He looked at her eyes straightly for a second before talking.

Preshantha I needed to say this much earlier but I couldn’t… I couldn’t cheat my best friend.”

For the next one or two seconds none of the two speak.

Rohan broke the silence.

I can’t go on a year without seen you Preshantha. Can you?” Rohan kept his gaze at her eyes while holding her hand in his both hands.

Now Preshantha is sure she too feels difficulties in leaving Rohan behind. Deep in her heart she felt the hatred she had for Rohan is changing for it opposite feeling. But she wanted to understand the clear reason for this sudden behavior of Rohan. She tried to calm down herself and understand the full meaning of his talk.

What are you talking about? Cheating me?”, Preshantha asked.

I have far more precious feeling toward you than my best friend should have”, was his answer.

---------------------------------------------------------------------------------------------------------------------------------
This was an entry for the Commonwealth Short Story Competition 2012.

Sunday, May 13, 2012

My Literal Blog Started.....

I planed to start a second blog in wordpress and dedicate it to literal work of mine in addition to this personal blog. You can check the new blog using below url. http://creationsofsurangi.wordpress.com

Friday, April 13, 2012

Dhammapada Quotations

The Dhammapada Quotes
Famous The Dhammapada Quotations

The Dhammapada is a versified Buddhist scripture traditionally ascribed to the Buddha himself. It is one of the best-known texts from the Theravada canon.

Saturday, March 31, 2012

A Recipe that went well





Cooking is not an alien thing to most of them. But to get favorable reply from the eaters of your recipes is not so easy as you may think.

Below is a recipes went well with me. This is a called a Billing Sambola and can be eaten with rice.

Billing Sambola

Ingredient:

50 Small billings

1 Table spoon of Maldives fish powder

Pinch of Saffron

2 Pieces of Ginger

1 Small pieces rampe

1 Karapincha leaves

Small piece of sera

Chili powder

Union and garlic

Cinnamon

Salt

Oil

Cut and Soak the billings in salt water for about half an hour. Take billings out of salt water and mix with all the other ingredients. Now put oil into a pan and temper all the ingredients for few minutes.

Friday, February 24, 2012

Drilldown Chart in ModalPopupExtender Control - ASP.NET



This is one of the R&D did sometimes back. But never had the chance to use it in the intended project. In the hope that this will be useful to anyone who will visit this site, I am going to publish it here. 


What this basically do is based on user inputs it will generate a bar chart with the Monthly stats/ productivity. If a user is interested in drill down the chart they need to click the particular week bar and it will give user a daily stats/productivity of that selected week in a model popup.(refer the screen shot below)

OK. Let's get started.


Figure 1.0

Classes used:
·         DateTimeWorks.cs: note this is a static class and hence can be called without first creating an object.
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Globalization;

namespace TXChart
{
    public static class DateTimeWorks
    {
        public static DateTime GetFirstDayOfWeek(DateTime dayInWeek)
        {
            CultureInfo defaultCultureInfo = CultureInfo.CurrentCulture;
            DayOfWeek firstDay = defaultCultureInfo.DateTimeFormat.FirstDayOfWeek;
            DayOfWeek day = DateTime.Now.DayOfWeek;
            int days = day - DayOfWeek.Monday;
            return GetFirstDateOfWeek(dayInWeek, firstDay);
        }
        public static DateTime GetFirstDateOfWeek(DateTime dayInWeek, DayOfWeek firstDay)
        {
            DateTime firstDayInWeek = dayInWeek.Date;
            while (firstDayInWeek.DayOfWeek != firstDay)
                firstDayInWeek = firstDayInWeek.AddDays(-1);
            return firstDayInWeek;
        }
        public static DateTime GetLastDateOfWeek(DateTime dayInWeek, DayOfWeek lastDayOfWeek)
        {
            DateTime lastDayInWeek = dayInWeek.Date;
            while (lastDayInWeek.DayOfWeek != lastDayOfWeek)
                lastDayInWeek = lastDayInWeek.AddDays(1);
            return lastDayInWeek;
        }      
        public static int GetWeekNumberOfDate(DateTime dayInWeek)
        {
            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
            System.Globalization.Calendar cal = dfi.Calendar;
            return cal.GetWeekOfYear(dayInWeek, dfi.CalendarWeekRule,
            dfi.FirstDayOfWeek);
           
        }
        //get the date of the first(Mon) day in the week (weekNum should be >=1)
       public static DateTime FirstDateOfWeek(int year, int weekNum)
        {           
                DateTime jan1 = new DateTime(year, 1, 1);

                int daysOffset = DayOfWeek.Monday - jan1.DayOfWeek;
                DateTime firstMonday = jan1.AddDays(daysOffset);
                //if(firstMonday.DayOfWeek == DayOfWeek.Monday)
               
                var cal = CultureInfo.CurrentCulture.Calendar;
                int firstWeek = cal.GetWeekOfYear(jan1, CalendarWeekRule.FirstDay, DayOfWeek.Monday);

                if (firstWeek <= 1)
                {
                    weekNum -= 1;
                }

                DateTime result = firstMonday.AddDays(weekNum * 7);

                return result;
            }

       //get the date of the last(sat) day in the week (weekNum should be >=1)
       public static DateTime LastDateOfWeek(int year, int weekNum)
       {
          
           DateTime jan1 = new DateTime(year, 1, 1);

           int daysOffset = DayOfWeek.Saturday - jan1.DayOfWeek;
          
           DateTime firstSaturday= jan1.AddDays(daysOffset);
           //if(firstMonday.DayOfWeek == DayOfWeek.Monday)

           var cal = CultureInfo.CurrentCulture.Calendar;
           int firstWeek = cal.GetWeekOfYear(jan1, CalendarWeekRule.FirstDay, DayOfWeek.Saturday);
          
           if (firstWeek <= 1)
           {
               weekNum -= 1;
           }

           DateTime result =firstSaturday.AddDays(weekNum * 7);

           return result;
       }
        public static int BusinessDaysUntil(this DateTime firstDay, DateTime lastDay, params DateTime[] currentHolidays)
        {
            firstDay = firstDay.Date;
            lastDay = lastDay.Date;
            if (firstDay > lastDay)
            {
                throw new ArgumentException("Incorrect last day " + lastDay);
            }
            TimeSpan span = lastDay - firstDay;
            int businessDays = span.Days + 1;
            int fullWeekCount = businessDays / 7;
            // find out if there are weekends during the time exceedng the full weeks
            if (businessDays > fullWeekCount * 7)
            {
                // we are here to find out if there is a 1-day or 2-days weekend
                // in the time interval remaining after subtracting the complete weeks
                int firstDayOfWeek = (int)firstDay.DayOfWeek;
                int lastDayOfWeek = (int)lastDay.DayOfWeek;
                if (lastDayOfWeek < firstDayOfWeek)
                    lastDayOfWeek += 7;
                if (firstDayOfWeek <= 6)
                {
                    if (lastDayOfWeek >= 7)
                        // Both Saturday and Sunday are in the remaining time interval
                        businessDays -= 2;
                    else
                        if (lastDayOfWeek >= 6)
                            // Only Saturday is in the remaining time interval
                            businessDays -= 1;
                }
                else
                    if (firstDayOfWeek <= 7 && lastDayOfWeek >= 7)// Only Sunday is in the remaining time interval
                    {
                        businessDays -= 1;
                    }
            }
            // subtract the weekends during the full weeks in the interval
            businessDays -= fullWeekCount + fullWeekCount;
            // subtract the number of current holidays during the time interval
            foreach (DateTime curHoliday in currentHolidays)
            {
                DateTime bh = curHoliday.Date;
                if (firstDay <= bh && bh <= lastDay)
                    --businessDays;
            }
            return businessDays;
        }
        public static int BusinessDaysUntil(this DateTime firstDay, DateTime lastDay)
        {
            firstDay = firstDay.Date;
            lastDay = lastDay.Date;
            if (firstDay > lastDay)
            {
                throw new ArgumentException("Incorrect last day " + lastDay);
            }
            TimeSpan span = lastDay - firstDay;
            int businessDays = span.Days + 1;
            int fullWeekCount = businessDays / 7;
            // find out if there are weekends during the time exceedng the full weeks
            if (businessDays > fullWeekCount * 7)
            {
                // we are here to find out if there is a 1-day or 2-days weekend
                // in the time interval remaining after subtracting the complete weeks
                int firstDayOfWeek = (int)firstDay.DayOfWeek;
                int lastDayOfWeek = (int)lastDay.DayOfWeek;
                if (lastDayOfWeek < firstDayOfWeek)
                    lastDayOfWeek += 7;
                if (firstDayOfWeek <= 6)
                {
                    if (lastDayOfWeek >= 7)
                        // Both Saturday and Sunday are in the remaining time interval
                        businessDays -= 2;
                    else
                        if (lastDayOfWeek >= 6)
                            // Only Saturday is in the remaining time interval
                            businessDays -= 1;
                }
                else
                    if (firstDayOfWeek <= 7 && lastDayOfWeek >= 7)// Only Sunday is in the remaining time interval
                    {
                        businessDays -= 1;
                    }
            }
            // subtract the weekends during the full weeks in the interval
            businessDays -= fullWeekCount + fullWeekCount;
            return businessDays;
        }

    }
}
·         Productivity.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace TXChart
{
    public class Productivity
    {
       private DateTime _startdate;
       private DateTime _enddate;
       private int _roleid;
       private string _type;
       //week details are gathered from the selected date belonged week (from Monday to Saturday).
       //based on the role id individual or team)
        public Productivity(DateTime SelectedDate, int RoleID, string type)
        {
            _startdate = TXChart.DateTimeWorks.GetFirstDateOfWeek(SelectedDate, DayOfWeek.Monday);
            _enddate = TXChart.DateTimeWorks.GetLastDateOfWeek(SelectedDate, DayOfWeek.Saturday);
          
            _roleid = RoleID;
            _type = type;
        }
        //Current week details are gathered
        public Productivity(int RoleID)
        {
            _startdate = TXChart.DateTimeWorks.GetFirstDateOfWeek(DateTime.Now, DayOfWeek.Monday);
            _enddate = TXChart.DateTimeWorks.GetLastDateOfWeek(DateTime.Now, DayOfWeek.Saturday);
           
            _roleid = RoleID;
        }
       
        //week details are gathered from the provided weekno & year.
        public Productivity(int Year, int WeekNo, int RoleID)
        {
            _startdate = TXChart.DateTimeWorks.FirstDateOfWeek(Year,WeekNo);
            _enddate = TXChart.DateTimeWorks.LastDateOfWeek(Year, WeekNo);
            _roleid = RoleID;
        }
        //get month details from the selected weekno.
        public Productivity(int Year, int WeekNo, int RoleID, string type)
        {
            if (type == "Weekly")
            {
                _startdate = TXChart.DateTimeWorks.FirstDateOfWeek(Year, WeekNo);
                _enddate = TXChart.DateTimeWorks.LastDateOfWeek(Year, WeekNo);
                _roleid = RoleID;
                _type = type;
            }
            if (type == "Monthly")
            {
                DateTime startdate = TXChart.DateTimeWorks.FirstDateOfWeek(Year, WeekNo);
                //_startdate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                _startdate = new DateTime(startdate.Year, startdate.Month, 1);
                //_enddate = _startdate.AddMonths(1).AddDays(-1);
                _enddate = _startdate.AddMonths(1).AddDays(-1);
                _roleid = RoleID;
                _type = type;
            }
        }
        protected static string GetConnectionString()
        {
            return ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        }
        //Generate weekly report for an agent
        public DataSet ProductivityData(string agentid)
        {
            DataSet prodData = new DataSet();
            if (_roleid == 4)
            {
                if (_type == "Weekly")
                {
                   prodData = GetStats(agentid, _startdate.ToString(), _enddate.ToString());
                }
               if (_type == "Monthly")
                {
                    prodData = WeeklyGetStats(agentid, _startdate.ToString(), _enddate.ToString());
                }
            }
            return prodData;
        }
       
        private DataSet GetStats(string agentid, string fromdate, string todate)
        {
            using (SqlConnection cnnCon = new SqlConnection( GetConnectionString()))
            {
                SqlCommand cmdImStats = new SqlCommand();
                cmdImStats.Connection = cnnCon;
                cmdImStats.CommandType = CommandType.StoredProcedure;
                cmdImStats.CommandText = "sp_Test_GetProductivityEV";
                cmdImStats.Parameters.Add("@agentID", SqlDbType.NVarChar);
                cmdImStats.Parameters.Add("@fromDate", SqlDbType.Date);
                cmdImStats.Parameters.Add("@toDate", SqlDbType.Date);
                cmdImStats.Parameters["@agentID"].Value = agentid;
                cmdImStats.Parameters["@fromDate"].Value = fromdate;
                cmdImStats.Parameters["@toDate"].Value = todate;
                SqlDataAdapter daImStats = new SqlDataAdapter(cmdImStats);
                DataSet dsImStats = new DataSet();
                daImStats.Fill(dsImStats);
                return dsImStats;
         }
        }
        private DataSet WeeklyGetStats(string agentid, string fromdate, string todate)
        {
            using (SqlConnection cnnCon = new SqlConnection(GetConnectionString()))
            {
                SqlCommand cmdImStats = new SqlCommand();
                cmdImStats.Connection = cnnCon;
                cmdImStats.CommandType = CommandType.StoredProcedure;
                //cmdImStats.CommandText = "sp_Test_WeeklyGetProductivityEV";
                cmdImStats.CommandText = "sp_Test_WeeklyGetProductivityEV";
                cmdImStats.Parameters.Add("@agentID", SqlDbType.NVarChar);
                cmdImStats.Parameters.Add("@fromDate", SqlDbType.Date);
                cmdImStats.Parameters.Add("@toDate", SqlDbType.Date);
                cmdImStats.Parameters["@agentID"].Value = agentid;
                cmdImStats.Parameters["@fromDate"].Value = fromdate;
                cmdImStats.Parameters["@toDate"].Value = todate;
                SqlDataAdapter daImStats = new SqlDataAdapter(cmdImStats);
                DataSet dsImStats = new DataSet();
                daImStats.Fill(dsImStats);
                return dsImStats;


            }}}}   
    Add an .aspx page to the solution (Chart1.aspx)
·         Design of the interface
Figure 2.0

<asp:CHART ID="TChart1" runat="server" BackColor="Silver"
            BackGradientStyle="TopBottom" BorderColor="181, 64, 1" BorderDashStyle="Solid"
            BorderWidth="2" Height="272px" Width="680px" EnableViewState="True"
            IsMapAreaAttributesEncoded="True" onclick="TChart1_Click">
            <titles>
                <asp:Title Font="Trebuchet MS, 14.25pt, style=Bold" ForeColor="26, 59, 105"
                    Name="Title1" ShadowColor="32, 0, 0, 0" ShadowOffset="3" Text="Weekly Chart">
                asp:Title>
            titles>
            <legends>
                <asp:Legend BackColor="Transparent" Enabled="True"
                    Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="True" Name="Default"
                    TitleFont="Microsoft Sans Serif, 8pt, style=Bold" Alignment="Near" TitleAlignment="Near">                   
                asp:Legend>
            legends>
            <borderskin skinstyle="Emboss" />
            <series>
                                         <asp:Series Name="Enter" BorderColor="180, 26, 59, 105">asp:Series>
                                         <asp:Series Name="Verify" BorderColor="180, 26, 59, 105">asp:Series>
                     series>
            <chartareas>
                <asp:ChartArea BackColor="OldLace" BackGradientStyle="TopBottom"
                    BackSecondaryColor="White" BorderColor="64, 64, 64, 64" Name="ChartArea1"
                    ShadowColor="LightGray">
                    <area3dstyle inclination="15" isclustered="False" isrightangleaxes="False"
                        perspective="10" rotation="10" wallwidth="0" />
                    <axisy labelautofitmaxfontsize="8" linecolor="64, 64, 64, 64">
                        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold"  />
                        <majorgrid linecolor="64, 64, 64, 64" />
                    axisy>
                    <axisx labelautofitmaxfontsize="8" linecolor="64, 64, 64, 64">
                        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" Format="MM-dd"
                            IsEndLabelVisible="False" />
                        <majorgrid linecolor="64, 64, 64, 64" />
                    axisx>
                asp:ChartArea>
            chartareas>
        asp:CHART>
·         Chart1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.DataVisualization.Charting;

·         Chart button click event
protected void btnChart_Click(object sender, EventArgs e)
        {
            Productivity prod = new Productivity(4);
            if (txtWeek.Text.Trim() != "")
            {
                if (ddlType.SelectedItem.ToString().Trim() == "Weekly")
                {
                    prod = new Productivity(Convert.ToInt32(ddlYear.SelectedItem.ToString()), Convert.ToInt32(txtWeek.Text), 4,"Weekly");
                }
                if (ddlType.SelectedItem.ToString().Trim() == "Monthly")
                {
                    prod = new Productivity(Convert.ToInt32(ddlYear.SelectedItem.ToString()), Convert.ToInt32(txtWeek.Text), 4, "Monthly");
                }
            }
            DataSet ds = prod.ProductivityData(txtAgentID.Text.Trim());
            TChart1.DataSource = ds;

            TChart1.Series["Enter"].XValueMember = "PDate";
            TChart1.Series["Enter"].YValueMembers = "Entery Count";
            TChart1.Series["Enter"].Name = "Enter";
            TChart1.ChartAreas[0].AxisY.Title = "Batch Count";
            TChart1.Series["Verify"].XValueMember = "PDate";
            TChart1.Series["Verify"].YValueMembers = "Verify Count";
            TChart1.Series["Verify"].Name = "Verify";
            TChart1.Titles[0].Text = ddlType.SelectedItem.ToString().Trim()+" Chart";//Based on report type
            TChart1.DataBind();
            if (ddlType.SelectedItem.ToString().Trim() != "Weekly")
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    TChart1.Series[0].Points[i].PostBackValue = ds.Tables[0].Rows[i]["PDate"].ToString();
                    TChart1.Series[1].Points[i].PostBackValue = ds.Tables[0].Rows[i]["PDate"].ToString();
                }}
            for (int i = 0; i < TChart1.Series[0].Points.Count; i++)
            {
                string X_val = ds.Tables[0].Rows[i]["PDate"].ToString();
                TChart1.Series[0].Points[i].ToolTip = X_val;
                TChart1.Series[0].Points[i].AxisLabel = X_val.ToString();
                TChart1.Series[1].Points[i].ToolTip = X_val;
                TChart1.Series[1].Points[i].AxisLabel = X_val.ToString();
            }}
·         Style
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Chart1.aspx.cs" Inherits="TXChart.Chart1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>title>
    <style type="text/css">
       .block
       {            
            background-color: gray;
            filter: alpha(opacity=30);
       }
    style>head>

·         Trick1:Button1 is used as the TargetControl Id in the ModalPopupExtender but it’s visibility is falls in the page load time as we are not going to use it to trigger the modalpopup.
·         Trick2:block style is used as the BackgroundCssClass for modalpopup to block the background when it triggerd.But it is not truly blocking the controls.

protected void Page_Load(object sender, EventArgs e)
        {
                        Button1.Style.Add("display", "none");
     }

<asp:Button ID="Button1" runat="server" Text="Button" Height="26px" />

    <cc1:ModalPopupExtender ID="Button1_ModalPopupExtender"
    runat="server"
    TargetControlID="Button1"
    OkControlID="Button3"
    PopupControlID="Panel1" BackgroundCssClass="block"
        PopupDragHandleControlID="TCHART2">
    cc1:ModalPopupExtender>
Panel1

<asp:Panel ID="Panel1" BackColor="" runat="server"
    style="display:none;">
    <asp:Button ID="Button3" runat="server" Text="X" />
    <div>
<asp:CHART ID="TCHART2" runat="server" BackColor="Silver"
            BackGradientStyle="TopBottom" BorderColor="181, 64, 1" BorderDashStyle="Solid"
            BorderWidth="2" Height="272px" Width="680px" EnableViewState="True"
            IsMapAreaAttributesEncoded="True" onclick="TChart1_Click">
            <titles>
                <asp:Title Font="Trebuchet MS, 14.25pt, style=Bold" ForeColor="26, 59, 105"
                    Name="Title1" ShadowColor="32, 0, 0, 0" ShadowOffset="3" Text="Weekly Chart">
                asp:Title>
            titles>
            <legends>
                <asp:Legend BackColor="Transparent" Enabled="True"
                    Font="Trebuchet MS, 8.25pt, style=Bold" IsTextAutoFit="True" Name="Default"
                    TitleFont="Microsoft Sans Serif, 8pt, style=Bold" Alignment="Near" TitleAlignment="Near">                   
                asp:Legend>
            legends>
            <borderskin skinstyle="Emboss" />
            <series>
                                         <asp:Series Name="Enter" BorderColor="180, 26, 59, 105">asp:Series>
                                         <asp:Series Name="Verify" BorderColor="180, 26, 59, 105">asp:Series>
                     series>
            <chartareas>
                <asp:ChartArea BackColor="OldLace" BackGradientStyle="TopBottom"
                    BackSecondaryColor="White" BorderColor="64, 64, 64, 64" Name="ChartArea1"
                    ShadowColor="LightGray">
                    <area3dstyle inclination="15" isclustered="False" isrightangleaxes="False"
                        perspective="10" rotation="10" wallwidth="0" />
                    <axisy labelautofitmaxfontsize="8" linecolor="64, 64, 64, 64">
                        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold"  />
                        <majorgrid linecolor="64, 64, 64, 64" />
                    axisy>
                    <axisx labelautofitmaxfontsize="8" linecolor="64, 64, 64, 64">
                        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" Format="MM-dd"
                            IsEndLabelVisible="False" />
                        <majorgrid linecolor="64, 64, 64, 64" />
                    axisx>
                asp:ChartArea>
            chartareas>
        asp:CHART>
div>asp:Panel> form>body>html>

·         Chart1_click event  Chart2 will be binded based on the selected Chart1 series

protected void TChart1_Click(object sender, ImageMapEventArgs e)
        {
            string region, year = "";
            if ((e.PostBackValue != null) && (TChart1.Titles[0].Text != "Weekly Chart"))
            {
                region = e.PostBackValue;
                year =ddlYear.SelectedItem.Text.ToString();
                TCHART2.Titles[0].Text = region + " - Weekly Chart";
                Productivity prod = new Productivity(Convert.ToInt32(year), Convert.ToInt32(region), 4, "Weekly");
                DataSet ds = prod.ProductivityData("GA43");
                TCHART2.DataSource = ds;
                TCHART2.Series["Enter"].XValueMember = "PDate";
                TCHART2.Series["Enter"].YValueMembers = "Entery Count";
                TCHART2.Series["Enter"].Name = "Enter";
                TCHART2.ChartAreas[0].AxisY.Title = "Batch Count";
                TCHART2.Series["Verify"].XValueMember = "PDate";
                TCHART2.Series["Verify"].YValueMembers = "Verify Count";
                TCHART2.Series["Verify"].Name = "Verify";
                TCHART2.Titles[0].Text = "Weekly Chart";//Based on report type
                TCHART2.DataBind();
            }
         
            Button1_ModalPopupExtender.Show();
        }
Figure 3.0

When click on one of the series from 1 to 4 based on the selection the weekly chart pops up as shown in the top Figure 1.0