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");
            }
        }
        void btnUpdateLeadDetail_Click(object sender, RoutedEventArgs e)
        {
            //throw new Exception("The method or operation is not implemented.");
            try
            {
                int    flagChk = 1;
                int    flagCol = 1;
                string chk     = "";

                if (cmbSelection.ToLower() == "text")
                {
                    chk = txtFieldStartPosition.Text;
                }
                else
                {
                    chk = cmbColumn.SelectionBoxItem.ToString();
                }



                foreach (ClsLeadFormatBusiness cl in objLeadFieldsCollection)
                {
                    if (cl.FieldName == cmbFieldName.SelectionBoxItem.ToString())
                    {
                        flagChk = 0;
                        break;
                    }
                }


                foreach (ClsLeadFormatBusiness cl in objLeadFieldsCollection)
                {
                    if (cl.StartPosition.ToString() == chk)
                    {
                        flagCol = 0;
                        break;
                    }
                }


                if (flagChk == 1 && flagCol == 1)
                {
                    objLeadFormat = new ClsLeadFormatBusiness();
                    objLeadFormat.LeadFieldsID = -1;
                    setLeadFormatValue();
                    int cnt = objLeadFormat.LeadFormatDesignerSave();

                    if (cnt > 0)
                    {
                        MessageBox.Show("New Record Inserted");
                        //funSetChildGrid(objLeadFormat.LeadFormatID);
                    }
                    else
                    {
                        MessageBox.Show("can not edit");
                    }
                }
                else if (flagChk == 0 && flagCol == 1)
                {
                    objLeadFormat = new ClsLeadFormatBusiness();
                    objLeadFormat.LeadFieldsID = LeadsFieldID;
                    setLeadFormatValue();
                    int cnt = objLeadFormat.LeadFormatDesignerSave();

                    if (cnt > 0)
                    {
                        MessageBox.Show("One Record Updated");
                        //funSetChildGrid(objLeadFormat.LeadFormatID);
                    }
                    else
                    {
                        MessageBox.Show("can not edit");
                    }
                }
                else if (flagChk == 0 && flagCol == 0 && (TmpDefaultValue.ToLower() != txtDefaultValue.Text.ToLower() || TmpFieldLength.ToLower() != txtFieldLength.Text.Trim(' ').ToLower()))
                {
                    //objLeadFormat.LeadFieldsID = LeadsFieldID;
                    objLeadFormat = new ClsLeadFormatBusiness();
                    setLeadFormatValue();
                    int cnt = objLeadFormat.LeadFormatDesignerSave();

                    if (cnt > 0)
                    {
                        MessageBox.Show("One Record Updated");
                        funSetChildGrid(objLeadFormat.LeadFormatID);
                        TmpDefaultValue = objLeadFormat.DefaultValue;
                        if (objLeadFormat.Length == 0)
                        {
                            TmpFieldLength = "";
                        }
                        else
                        {
                            TmpFieldLength = objLeadFormat.Length.ToString();
                        }
                    }
                    else
                    {
                        MessageBox.Show("can not Updated , try again");
                    }
                }
                else
                {
                    MessageBox.Show("Field Name and Column Name is already assigned");
                }
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message);
                //}

                //shilpa code
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
                VMuktiHelper.ExceptionHandler(ex, "btnUpdateLeadDetail_Click()", "ctlLeadFormatDesigner.xaml.cs");
            }

            if (parentRow != -1)
            {
                funSetChildGrid(parentRow);
            }
        }