void CtlGrid_btnDeleteClicked(int rowID)
 {
     try
     {
         if (MessageBox.Show("Are You sure You want to remove the Lead Format?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             Int64 varID = 0;
             //tbcDispositionsCheck();
             varID = Convert.ToInt64(objLeadCollection[rowID].ID);
             //int DelFormat = ClsLeadFormatBusiness.LeadFields_GetByID(varID);
             int DelFormat = ClsLeadFormatBusiness.DeleteLeadField_ByID(varID);
             if (DelFormat > 0)
             {
                 MessageBox.Show("Lead Format is Deleted Sucessfully");
             }
             else
             {
                 MessageBox.Show("Lead Format can not be Deleted");
             }
             txtLeadFormatName.Text = "";
             funSetGrid();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        void CtlGridChild_btnEditClicked(int rowID)
        {
            //shilpa code

            //parentRow = rowID;
            //end
            Int64 varID = 0;

            try
            {
                tbcDispositionsCheck();

                varID           = Convert.ToInt64(objLeadFieldsCollection[rowID].LeadFormatID);
                LeadsFieldID    = objLeadFieldsCollection[rowID].LeadFieldsID;
                TmpDefaultValue = objLeadFieldsCollection[rowID].DefaultValue;

                if (objLeadFieldsCollection[rowID].Length == 0)
                {
                    TmpFieldLength = "";
                }
                else
                {
                    TmpFieldLength = objLeadFieldsCollection[rowID].Length.ToString();
                }

                objLeadFormat = new ClsLeadFormatBusiness();
                objLeadFormat = ClsLeadFormatBusiness.LeadFields_GetByID(varID);

                cmbFieldName.Text    = objLeadFieldsCollection[rowID].FieldName;
                txtDefaultValue.Text = objLeadFieldsCollection[rowID].DefaultValue;

                if (cmbSelection.ToLower() == "excel" || cmbSelection.ToLower() == "csv")
                {
                    cmbColumn.Text   = objLeadFieldsCollection[rowID].StartPosition.ToString();
                    TmpStartPosition = objLeadFieldsCollection[rowID].StartPosition;
                }
                else
                {
                    txtFieldStartPosition.Text = objLeadFieldsCollection[rowID].StartPosition.ToString();
                    txtFieldLength.Text        = objLeadFieldsCollection[rowID].Length.ToString();
                    cmbDelimiter.Text          = objLeadFieldsCollection[rowID].Delimiters.ToString();
                }
                btnUpdateLeadDetail.Visibility = Visibility.Visible;
                btnDone.Visibility             = Visibility.Visible;
                btnSave.Visibility             = Visibility.Hidden;
            }
            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "CtlGridChild_btnEditClicked()", "ctlLeadFormatDesigner.xaml.cs");
            }
        }
        void CtlGrid_btnEditClicked(int rowID)
        {
            Int64 varID = 0;

            //MessageBox.Show("clicked");
            try
            {
                varID         = Convert.ToInt64(objLeadCollection[rowID].ID);
                curID         = varID;
                isEditing     = true;
                objLeadFormat = new ClsLeadFormatBusiness();
                objLeadFormat = ClsLeadFormatBusiness.GetByLeadFormatID(varID);

                txtLeadFormatName.Text = objLeadFormat.LeadFormatName;
                if (objLeadFormat.FormatType.ToLower() == "excel")
                {
                    cmbFormatType.SelectedIndex = 0;
                }
                else if (objLeadFormat.FormatType.ToLower() == "text")
                {
                    cmbFormatType.SelectedIndex = 1;
                }
                else
                {
                    cmbFormatType.SelectedIndex = 2;
                }

                txtDescription.Text = objLeadFormat.Description;

                CtlGrid.Visibility        = Visibility.Hidden;
                CtlGridChild.Visibility   = Visibility.Visible;
                btnNext.Visibility        = Visibility.Hidden;
                cmbFormatType.IsEnabled   = false;
                tbiDispositions.IsEnabled = true;
                tbcDispositionsCheck();
                funSetChildGrid(varID);
                btnUpdateLead.Visibility       = Visibility.Visible;
                btnUpdateLeadDetail.Visibility = Visibility.Hidden;
                btnSave.Visibility             = Visibility.Visible;
                TempString1 = txtLeadFormatName.Text;
            }
            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "CtlGrid_btnEditClicked()", "ctlLeadFormatDesigner.xaml.cs");
            }
        }
 public void CtlGridChild_btnDeleteClicked(int rowID)
 {
     try
     {
         if (MessageBox.Show("Are You sure You want to remove the Lead Format Field?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             Int64 varID = 0;
             varID = Convert.ToInt64(objLeadFieldsCollection[rowID].LeadFieldsID);
             int DelLeadField = ClsLeadFormatBusiness.DeleteFormatField_ByID(varID);
             //funSetChildGrid();
             if (parentRow != -1)
             {
                 funSetChildGrid(parentRow);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        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);
            }
        }