Tuesday, 23 April 2013

5 things to remember during an exit interview

5 things to remember during an exit interview
 
If you have resigned from a company and you are being called by HR for exit interview, you should face HR very politely and maintain a positive attitude. Here are some points I wanted to discuss with you on exit interviews.
 
1. Maintain your composure: You might come across very trivial questions but maintaining your composure is very critical, no matter how irrelevant you feel they might be. Be graceful and witty while answering tricky questions.
 
2. Emphasis on your experience: Discuss your experiences and key learning from them. Always mention about the opportunities those were given to you and how you were able to perform on them, which has enhanced your skills for future endeavours.
 
3. Don’t be negative:  Focus on the key learning from difficult situations at the work place. You should portray that every crisis had given an opportunity for you to be adaptable in different situations and be a quick fixer to any given problem.
 
4. Comments should be constructive: Be honest but polite while putting across your grievances. Instead of accusing anyone or any process, try giving examples on how it can be improved for better results.
 
5. Don’t take out personal grudge: It’s better to express your problems in a non-personal way rather pin-pointing it to any individual. Remember, it is unnecessary for you to comment on someone (negatively) who you are not going to see for much longer.

How to crack a Telephonic Interview? Things to keep in mind while Telephonic Interview

How to crack a Telephonic Interview? Things to keep in mind while Telephonic Interview
 
A telephonic interview is usually organised to short-list candidates, to minimise the cost of conducting face-to-face interviews or to screen outstation candidates.
 
This is an important step for both the interviewer and the interviewee. Just as a personal interview, there are some basic dos and don’ts. It is very critical to follow these as the difficult task here is to impress the interviewer on the phone and hold their attention for the entire conversation.Therefore:
 
Be serious: It is a job interview at the end of the day. So first rule is that one must treat a telephonic interview just as one would treat a face-to-face meeting.This means keeping your resume handy, making sure you get the name and designation of the interviewer right and most importantly avoid multitasking.
 
The same rule also applies to an interviewer. The interviewer must spend some time before the call to study the resume and also must ensure that they are not distracted by any other work at that point in time.
 
Avoid distractions: It is important to choose a quiet place to take the call. You don’t want to be distracted by background noise. If possible use a landline to avoid call drops. If you are using your mobile phone, ensure that your call-wait facility is switched off.
 
For interviewer it is equally important to show seriousness. Don’t interrupt the call. This can be very discouraging to an interviewee.
 
Maintain the tone: The difficult task in a telephonic interview is that one needs to put forth their best voice. Yes, that’s right. That’s the only interface you have with your interviewer. So maintain a normal tone, don’t get excited and more importantly don’t raise your voice at any given point. Further it is important that the candidate speaks slowly and clearly.
 
Be positive: You have to be extra careful about expressing the right attitude. So, say your ‘hello’ with a smile. Studies have shown that smiling on the phones creates a positive image. Also, it kind of adds a spring to your voice, makes you sound professional and confident.
 
Listen intently: Listening attentively is an important aspect of an interview. This is more so in case of a telephonic interview. It is important to listen carefully and answering honestly. On a telephone any slight hesitation is evident. However, don’t jump to answer a question immediately. Listen carefully and articulate it well before saying out loud.
 
Lastly, don’t rush through the interview. Take your time, sound prepared, take notes, if required. This will help you to create a positive image. Also, remember since it’s a telephonic interview you get a chance to keep all the information you may require handy. This could be your resume, notes about the company, job profile and so on. This is your cheat sheet – use it wisely.

Monday, 22 April 2013

How to Select XML Nodes by Attribute Value using XPath expression in C#?

How to Select XML Nodes by Attribute Value using XPath expression in C#?
 
This example shows how to select nodes from XML document by attribute value. Use method XmlNode.SelectNodes to get list of nodes selected by the XPath expression. Suppose we have this XML file.
 
<Names>
    <Name type="M">John</Name>
    <Name type="F">Susan</Name>
    <Name type="M">David</Name>
</Names>
 
To get all name nodes use XPath expression /Names/Name. To get only male names (to select all nodes with specific XML attribute) use XPath expression /Names/Name[@type='M'].
 
XmlDocument xml = new XmlDocument();
xml.LoadXml(myXMLDocPath);  //Path of XML file
XmlNodeList xnList = xml.SelectNodes("/Names/Name[@type='M']");

foreach (XmlNode xn in xnList)
{
  Console.WriteLine(xn.InnerText);
}

 
The output is:
John
David

How to get child nodes of an element in an XML in a WPF application?

How to get child nodes of an element in an XML in a WPF application? 
 
While parsing an XML in a WPF application, I fell in a need to fetch the child nodes of an element. I put the question on stackoverflow and got many responses but at last I was able to answer that question myself.
 
Lets consider the problem:
 
Suppose I have following XML
 
<Loop Name="MasterData">
  <Loop Name="SlaveData">
    <Segment Name="AAA">
      <Node1>hello</Node1>
      <Node2>john</Node2>
      <Node3>hi</Node3>
      <Node4>marry</Node4>
    </Segment>
    <Segment Name="BBB">
      <Node1>00</Node1>
      <Node2> </Node2>
      <Node3>00</Node3>
      <Node4> </Node4>
    </Segment>
   </Loop>
</Loop>  
 
Now I have to get the values of Node1, Node2, Node3, Node4 ie, hello, john, hi, marry in a list whose parent element is Segment with Name as "AAA". So first of all I will try to reach at segment with name attribute as "AAA" and then I will check whether that elements has child nodes or not. If that segment element contains child nodes, then I will fetch the innertext of all the child nodes.
 
Below is the C# code for fetching the child nodes of an element
 
public static void GetChildElements()
{
    List<string> lstChildElements = new List<string>();
   XmlDocument xmlDocument = new XmlDocument();
   xmlDocument.Load(XMLFileLocation);

   XmlNodeList xnList = xmlDocument.SelectNodes("/Loop/Loop/Segment[@Name='AAA']");
   foreach (XmlNode xn in xnList)
   {
     if (xn.HasChildNodes)
     {
       foreach (XmlNode childNode in xn.ChildNodes)
       {
          lstISAElements.Add(childNode.InnerText.ToString());
       }
     }
   }
   foreach (string childElement in lstChildElements)
   {
     Console.WriteLine(childElement);
   }
     
}

How to store and get database connection string from app.config file in WPF application in VS2012?


How to store and get database connection string from app.config file in WPF application in VS2012?

Storing and getting a database connection string from app.config is a very common practice used in every WPF application. I will make you understand this concept in following 3 steps:

Step 1: Store database connection string in your WPF app.config file like below:

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="MyConnectionString"
              connectionString="Data Source=myComputerName\sqlexpress;Initial  Catalog=MY_DB;User ID=user;Password=password/>
  </connectionStrings>
</configuration>


Step 2: Now include System.Configuration namespace in your application. But note that you also have to add reference of System.Configuration file in case if you are using Visual Studio 2012. Go to references and add System.Configuration namespace from there.

using System.Configuration;

Step 3: Add following line to get the database connection string in your class file. I have used ConfigurationManager to get the database connection string from app.config.

var connectionString=ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;

This concludes the article and hope you have understood the concept of how to store and get database connection string from app.config file in WPF application in VS2012?

Friday, 19 April 2013

WPF DataGrid Tutorials: DataGrid Properties and Features

WPF DataGrid Tutorials: DataGrid Properties and Features

WPF DataGrid has a lot of amazing features and properties which you can implement with ease in your application. WPF DataGrid provides a lot of properties which you can set to get your desired look and feel.

To show a basic WPF datagrid, just drop a DataGrid control to your view and bind the ItemsSource to a collection of data objects. The DataGrid provides a feature called AutoGenerateColumns that automatically generates column according to the public properties of your data objects.

<DataGrid ItemsSource="{Binding Customers}"  AutoGenerateColumns="False" />

The ItemSource property of DataGrid is the key to data binding. You can bind any data source that implements IEnuemerable. Each row in the DataGrid is bound to an object in the data source and each column in the DataGrid is bound to a property of the data source objects.

WPF DataGrid generates the following types of columns:

DataGridCheckBoxColumn for boolean values
DataGridComboBoxColumn for enumerable values
DataGridHyperlinkColumn for Uri values
DataGridTemplateColumn to show any types of data by defining your own cell template
DataGridTextColumn to show text values

WPF DataGrid Properties are listed below:

CanUserReorderColumns enables or disables column re-ordering
CanUserResizeColumns enables or disables column resizing
CanUserResizeRows enables or disables row resizing
CanUserSortColumns enables or disables column sorting

Grid Background, Row Background

<DataGrid ItemsSource="{Binding Customers}" Background="LightGray" RowBackground="LightYellow"/>

AlternatingRowBackground: You can define a an AlternatingRowBackground that is applied every even row. You can additionally specify an AlternationCount if you only want to ink every n-th data row.

<DataGrid ItemsSource="{Binding Customers}" AlternatingRowBackground="Gainsboro"  AlternationCount="2"/>

ColumnWidth and RowHeight properties of DataGrid are used to set the default column width and row height of DataGrid columns and rows.

GridLinesVisibility property is used to make grid lines visible. Using this option you can show and hide vertical, horizontal, all, or none lines.

SelectionMode can be set to Single or Extended to define if one or multiple units can be selected simultaneously.

SelectionUnit defines the scope of one selection unit. It can be set to Cell, CellAndRowHeader and FullRow.
 
BorderBrush and BorderThickness properties are used to set the color and width of the border.

IsReadOnly property is used to make a DataGrid read only. That means you cannot edit a DataGrid.

AreRowDetailsFrozen property is used to freeze the row details area so that it cannot be resized.

FrozenColumnCount: WPF datagrid supports the feature to freeze columns. That means they stay visible while you scoll horizontally through all columns. This is a useful feature to keep a referencing column like an ID or a name always visible to keep your orientation while scrolling.

<DataGrid ItemsSource="{Binding Customers}" FrozenColumnCount="2"  />

RowDetailsTemplate: WPF datagrid provides a feature that shows a detail panel for a selected row. It can be enabled by setting a DataTemplate to the RowDetailsTemplate property. The data template gets the object that is bound to this row passed by the DataContext and can bind to it.

HeadersVisibility: You can control the visibility of row and column headers by setting the HeadersVisibility property to either None,Row,Column or All.

<DataGrid ItemsSource="{Binding Customers}" HeadersVisibility="None" />

HorizontalScrollBarVisibility and VerticalScrollBarVisibility properties of type ScrollBarVisibility enumeration control the horizontal and vertical scrollbars of the DataGrid. It has four values - Auto, Disabled, Hidden, and Visible. The default value of these properties is Auto, that means, when scrolling is needed, you will see it, otherwise it will be hidden.

How to Bind WPF Datagrid with List of Objects?

How to Bind WPF Datagrid with List of Objects?

Lets say I have a class in which I have declared properties. I want to make objects of that class and store them in the list and finally bind that list to a WPF datagrid. The ItemSource property of DataGrid is the key to data binding. You can bind any data source that implements IEnuemerable. Each row in the DataGrid is bound to an object in the data source and each column in the DataGrid is bound to a property of the data source objects.

Lets dive in detail for more clear view.

I have created following class

public class Author
{
    public int ID { get; set; }
    public string Name { get; set; }      
    public DateTime DOB { get; set; }
    public string BookTitle { get; set; }
    public bool IsMVP  { get; set; }
}

Now let's create a collection of Author objects by using the List class.

private List<Author> LoadCollectionData()
{
    List<Author> authors = new List<Author>();
    authors.Add(new Author(){
            ID = 101,
            Name = "Mahesh Chand",
            BookTitle = "Graphics Programming with GDI+",
            DOB = new DateTime(1975, 2, 23),
            IsMVP = false });
    authors.Add(new Author()
    {
        ID = 201,
        Name = "Mike Gold",
        BookTitle = "Programming C#",
        DOB = new DateTime(1982, 4, 12),
        IsMVP = true
    });
    authors.Add(new Author()
    {
        ID = 244,
        Name = "Mathew Cochran",
        BookTitle = "LINQ in Vista",
        DOB = new DateTime(1985, 9, 11),
        IsMVP = true
    });
    return authors;
}

Now the last step is to set ItemsSource property of DataGrid. The following code snippet sets the ItemsSource property of a DataGrid to List of Authors.

MyDataGrid.ItemsSource = LoadCollectionData();

I think, you would have understood the concept on binding the list of objects with WPF datagrid ItemsSource property with this simple example.