void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool checkValue = false;
                if (((ListBoxItem)cmbFieldName.SelectedItem).Tag.ToString() == "")
                {
                    MessageBox.Show("Select Field Name");
                }
                else
                {
                    int affectedRow;

                    ClsLeadFormatBusiness LeadFormat = new ClsLeadFormatBusiness();
                    
                    if ((TempString1.ToLower() != txtLeadFormatName.Text.ToLower()) && flag == 0)
                    {
                        flag = 1;
                       // LeadFormat.LeadFormatID = -2;
                    }

                    else if ((TempString1.ToLower() == txtLeadFormatName.Text.ToLower()))
                    {
                        flag = 0;
                       // LeadFormat.LeadFormatID = curID;
                    }

                    TempString1 = txtLeadFormatName.Text;

                    LeadFormat.ID = -1;
                    LeadFormat.LeadFormatName = txtLeadFormatName.Text;
                    LeadFormat.FormatType = cmbFormatType.SelectionBoxItem.ToString();
                    LeadFormat.Description = txtDescription.Text;

                    LeadFormat.FieldID = Convert.ToInt64(((ListBoxItem)cmbFieldName.SelectedItem).Tag);

                    LeadFormat.DefaultValue = txtDefaultValue.Text;
                    //LeadFormat.LeadFormatID = -2;
                    LeadFormat.LeadFieldsID = -1;
                    LeadFormat.IsRequired = true;

                    if (isEditing)
                    {
                        LeadFormat.LeadFormatID = curID;
                    }
                    else
                    {
                        LeadFormat.LeadFormatID = -2;
                    }

                    if (cmbSelection == "excel" || cmbSelection == "csv")
                    {
                        if (cmbColumn.SelectionBoxItem.ToString() != "")
                        {
                            LeadFormat.StartPosition = int.Parse(cmbColumn.SelectionBoxItem.ToString());
                            LeadFormat.Length = 0;
                            LeadFormat.Delimiters = null;
                            checkValue = true;
                        }
                        else
                        {
                            checkValue = false;
                            MessageBox.Show("Select map column");
                        }
                    }
                    else
                    {
                        if (txtFieldStartPosition.Text == "" || txtFieldLength.Text == "" || cmbDelimiter.SelectionBoxItem.ToString() == "")
                        {
                            MessageBox.Show("Enter all required information");
                            checkValue = false;
                        }
                        else
                        {
                            LeadFormat.StartPosition = int.Parse(txtFieldStartPosition.Text);
                            LeadFormat.Length = int.Parse(txtFieldLength.Text);
                            LeadFormat.Delimiters = cmbDelimiter.SelectionBoxItem.ToString();
                            checkValue = true;
                        }
                    }
                    if (checkValue == true)
                    {
                        if (flag == 1)
                        {
                            affectedRow = LeadFormat.LeadFormatSave();
                            flag = 0;
                            //funSetGrid();
                        }


                        int cntInsert = 0;

                        cntInsert = LeadFormat.LeadFormatDesignerSave();
                        
                        if (cntInsert > 0)
                        {
                            cmbColumn.Items.Remove(cmbColumn.SelectedItem);
                            BlankFields();
                        }
                    }
                }

                if (parentRow != -1)
                {
                    CtlGrid.Visibility = Visibility.Hidden;
                    CtlGridChild.Visibility = Visibility.Visible;
                    btnUpdateLead.Visibility = Visibility.Visible;
                    btnNext.Visibility = Visibility.Hidden;
                    funSetChildGrid(parentRow);
                }
            }
            catch (NullReferenceException ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "btnSave_Click()", "ctlLeadFormatDesigner.xaml.cs");
            }
        }