private bool InsertCustomerPINInfo(NCR.EAI.AUB.Entity.CustomerPINInfo _custPINInfo)
        {
            string MethodName = MethodBase.GetCurrentMethod().Name;
            bool   inserted   = false;

            try
            {
                Logger.logDebug(ModuleName, MethodName, "**********Entered Method**********", Logger.LOGLEVEL.INFO);

                //check for IDNumber Masking. If should be maksed then do the masking
                //
                Logger.logDebug(ModuleName, MethodName, "Identity Number: " + _custPINInfo.IDENTITY_NUMBER, Logger.LOGLEVEL.INFO);

                Logger.logDebug(ModuleName, MethodName, "Inserting Customer", Logger.LOGLEVEL.INFO);


                string sqlQuery = "INSERT INTO CUSTOMER_PIN_INFO (IDENTITY_NUMBER,CUST_TYPE_CODE,PIN_TYPE_CODE,CUSTOMER_STATUS_CODE,UTILIZED_IVR_RETRIES,MAX_IVR_RETRIES,LAST_PIN_CHANGE_DATE,LAST_PIN_ENTRY_DATE,LAST_SUCCESFUL_AUTH_DATE,LAST_PIN_GENERATION_DATE,LAST_STATUS_UPDATE_DATE,CREATED_BY,CREATED_ON,UPDATED_BY,UPDATED_ON,IS_DELETED,DELETED_BY,DELETED_ON,AUTHORIZED_BY,AUTHORIZED_ON)";
                //string sqlQuery = "INSERT INTO CUSTOMER_PIN_INFO (IDENTITY_NUMBER, CUST_TYPE_CODE, PIN_TYPE_CODE, CUSTOMER_STATUS_CODE, UTILIZED_IVR_RETRIES,MAX_IVR_RETRIES, CREATED_BY, CREATED_ON, IS_DELETED)";
                //string sqlQuery = "INSERT INTO CUSTOMER_PIN_INFO ";
                string queryValues = "VALUES ('" + _custPINInfo.IDENTITY_NUMBER + "'," +
                                     "'" + _custPINInfo.CUST_TYPE_CODE + "'," +
                                     "'" + _custPINInfo.PIN_TYPE_CODE + "'," +
                                     "'" + _custPINInfo.CUSTOMER_STATUS_CODE + "'," +
                                     "" + _custPINInfo.UTILIZED_IVR_RETRIES + "," +
                                     "" + _custPINInfo.MAX_IVR_RETRIES + "," +
                                     "'" + _custPINInfo.LAST_PIN_CHANGE_DATE + "'," +
                                     "'" + _custPINInfo.LAST_PIN_ENTRY_DATE + "'," +
                                     "'" + _custPINInfo.LAST_SUCCESFUL_AUTH_DATE + "'," +
                                     "'" + _custPINInfo.LAST_PIN_GENERATION_DATE + "'," +
                                     "'" + _custPINInfo.LAST_STATUS_UPDATE_DATE + "'," +
                                     "'" + _custPINInfo.CREATED_BY + "'," +
                                     "'" + _custPINInfo.CREATED_ON + "'," +
                                     "'" + _custPINInfo.UPDATED_BY + "'," +
                                     "'" + _custPINInfo.UPDATED_ON + "'," +
                                     "" + _custPINInfo.IS_DELETED + "," +
                                     "'" + _custPINInfo.DELETED_BY + "'," +
                                     "'" + _custPINInfo.DELETED_ON + "'," +
                                     "'" + _custPINInfo.AUTHORIZED_BY + "'," +
                                     "'" + _custPINInfo.AUTHORIZED_ON + "'" +
                                     ")";

                sqlQuery = sqlQuery + queryValues;

                Logger.logDebug(ModuleName, MethodName, "Executing Query : " + sqlQuery, Logger.LOGLEVEL.INFO);

                if (bInsertMigDB)
                {
                    OledbSqlHelper _dbHelper = new OledbSqlHelper(DBDestConnString, bDBDestConnEncrypted);

                    inserted = _dbHelper.ExecuteNonQuery(sqlQuery);
                }
                else
                {
                    inserted = true;
                }

                if (inserted)
                {
                    writeSuccessQueriestoFile(sqlQuery);
                }
                else
                {
                    writeFailedQueriestoFile(sqlQuery);
                    writeFailedCustomerswithQuerytoFile(_custPINInfo.IDENTITY_NUMBER);
                }

                Logger.logDebug(ModuleName, MethodName, "Insert Result: " + inserted.ToString(), Logger.LOGLEVEL.INFO);

                return(inserted);
            }
            catch (Exception ex)
            {
                Logger.logDebug(ModuleName, MethodName, "Exception      : " + ex.Message, Logger.LOGLEVEL.INFO);
                if (ex.InnerException != null)
                {
                    Logger.logDebug(ModuleName, MethodName, "Inner Exception: " + ex.InnerException.Message, Logger.LOGLEVEL.INFO);
                }
                Logger.logDebug(ModuleName, MethodName, "**********Exiting Method**********", Logger.LOGLEVEL.INFO);

                MessageBox.Show(ex.Message);

                throw ex;
            }
        }
        private bool migrateCustomerPINInfo()
        {
            string       MethodName    = MethodBase.GetCurrentMethod().Name;
            DbDataReader _dataReader   = null;
            bool         customerFound = false;
            string       ModuleName    = "TPINMigrationUtility";

            try
            {
                Logger.logDebug(ModuleName, MethodName, "**********Entered Method**********", Logger.LOGLEVEL.INFO);

                OledbSqlHelper _dbHelper = new OledbSqlHelper(DBSourceConnString, bDBSourceConnEncrypted);

                Logger.logDebug(ModuleName, MethodName, "Fetching Records", Logger.LOGLEVEL.INFO);
                gstatus        = "Fetching Records";
                lblStatus.Text = gstatus;

                string sqlQuery = ConfigurationManager.AppSettings["RETREIVE_RECORDS_LIST"];
                Logger.logDebug(ModuleName, MethodName, "Executing Query : " + sqlQuery, Logger.LOGLEVEL.INFO);

                _dataReader = _dbHelper.ExecuteReader(sqlQuery);

                Logger.logDebug(ModuleName, MethodName, "Query executed. Retrieving Values", Logger.LOGLEVEL.INFO);

                gstatus        = "Parsing Records";
                lblStatus.Text = gstatus;

                if (_dataReader != null)
                {
                    if (_dataReader.HasRows)
                    {
                        while (_dataReader.Read())
                        {
                            customerFound = true;

                            NCR.EAI.AUB.Entity.CustomerPINInfo _custPINInfo = new NCR.EAI.AUB.Entity.CustomerPINInfo();

                            _custPINInfo.IDENTITY_NUMBER = _dataReader["IDENTITY_NUMBER"].ToString();
                            Logger.logDebug(ModuleName, MethodName, "CIF : " + _custPINInfo.IDENTITY_NUMBER, Logger.LOGLEVEL.WARNING);
                            _custPINInfo.CUST_TYPE_CODE       = _dataReader["CUST_TYPE_CODE"].ToString();
                            _custPINInfo.PIN_TYPE_CODE        = _dataReader["PIN_TYPE_CODE"].ToString();
                            _custPINInfo.CUSTOMER_STATUS_CODE = _dataReader["CUSTOMER_STATUS_CODE"].ToString();
                            _custPINInfo.UTILIZED_IVR_RETRIES = _dataReader["UTILIZED_IVR_RETRIES"].ToString();
                            _custPINInfo.MAX_IVR_RETRIES      = _dataReader["MAX_IVR_RETRIES"].ToString();
                            Logger.logDebug(ModuleName, MethodName, "Getting last pin change date", Logger.LOGLEVEL.WARNING);
                            _custPINInfo.LAST_PIN_CHANGE_DATE = FormatDate(_dataReader["LAST_PIN_CHANGE_DATE"].ToString(), DBSourceDateFormat, DBDestDateFormat);
                            Logger.logDebug(ModuleName, MethodName, "Getting last pin entry date", Logger.LOGLEVEL.WARNING);
                            _custPINInfo.LAST_PIN_ENTRY_DATE = FormatDate(_dataReader["LAST_PIN_ENTRY_DATE"].ToString(), DBSourceDateFormat, DBDestDateFormat);
                            Logger.logDebug(ModuleName, MethodName, "Getting last auth date", Logger.LOGLEVEL.WARNING);
                            _custPINInfo.LAST_SUCCESFUL_AUTH_DATE = FormatDate(_dataReader["LAST_SUCCESFUL_AUTH_DATE"].ToString(), DBSourceDateFormat, DBDestDateFormat);
                            Logger.logDebug(ModuleName, MethodName, "Getting last pin generation date", Logger.LOGLEVEL.WARNING);
                            _custPINInfo.LAST_PIN_GENERATION_DATE = FormatDate(_dataReader["LAST_PIN_GENERATION_DATE"].ToString(), DBSourceDateFormat, DBDestDateFormat);
                            Logger.logDebug(ModuleName, MethodName, "Getting last status update date", Logger.LOGLEVEL.WARNING);
                            _custPINInfo.LAST_STATUS_UPDATE_DATE = FormatDate(_dataReader["LAST_STATUS_UPDATE_DATE"].ToString(), DBSourceDateFormat, DBDestDateFormat);
                            _custPINInfo.CREATED_BY    = _dataReader["CREATED_BY"].ToString();
                            _custPINInfo.CREATED_ON    = FormatDate(_dataReader["CREATED_ON"].ToString(), DBSourceDateFormat, DBDestDateFormat);
                            _custPINInfo.UPDATED_BY    = _dataReader["UPDATED_BY"].ToString();
                            _custPINInfo.UPDATED_ON    = FormatDate(_dataReader["UPDATED_ON"].ToString(), DBSourceDateFormat, DBDestDateFormat);
                            _custPINInfo.IS_DELETED    = _dataReader["IS_DELETED"].ToString();
                            _custPINInfo.DELETED_BY    = _dataReader["DELETED_BY"].ToString();
                            _custPINInfo.DELETED_ON    = FormatDate(_dataReader["DELETED_ON"].ToString(), DBSourceDateFormat, DBDestDateFormat);
                            _custPINInfo.AUTHORIZED_BY = _dataReader["AUTHORIZED_BY"].ToString();
                            _custPINInfo.AUTHORIZED_ON = FormatDate(_dataReader["AUTHORIZED_ON"].ToString(), DBSourceDateFormat, DBDestDateFormat);



                            //translate the PIN
                            try
                            {
                                bool inserted = InsertCustomerPINInfo(_custPINInfo);
                                if (!inserted)
                                {
                                    throw new Exception("Unable to Add customer");
                                }
                                iSuccess       += 1;
                                lblSuccess.Text = iSuccess.ToString();
                            }
                            catch (Exception ex)
                            {
                                iFailed       += 1;
                                lblFailed.Text = iFailed.ToString();
                                Logger.logDebug(ModuleName, MethodName, "Exception      : " + ex.Message, Logger.LOGLEVEL.INFO);
                                //log query in a separate file

                                //
                            }
                            iProcessed       += 1;
                            lblProcessed.Text = iProcessed.ToString();
                        }
                    }
                    else
                    {
                        Logger.logDebug(ModuleName, MethodName, "No record found", Logger.LOGLEVEL.INFO);
                        customerFound = false;
                    }

                    _dataReader.Close();
                    //btnMigrate.Enabled = true;
                    gstatus        = "Finished";
                    lblStatus.Text = gstatus;
                }
                else
                {
                    Logger.logDebug(ModuleName, MethodName, "No Records Founds", Logger.LOGLEVEL.INFO);
                    customerFound      = false;
                    btnMigrate.Enabled = true;
                    gstatus            = "Finished";
                    lblStatus.Text     = gstatus;
                }
                Logger.logDebug(ModuleName, MethodName, "**********Exiting Method**********", Logger.LOGLEVEL.INFO);
                return(customerFound);
            }
            catch (Exception ex)
            {
                if (_dataReader != null)
                {
                    _dataReader.Close();
                }

                Logger.logDebug(ModuleName, MethodName, "Exception      : " + ex.Message, Logger.LOGLEVEL.INFO);
                if (ex.InnerException != null)
                {
                    Logger.logDebug(ModuleName, MethodName, "Inner Exception: " + ex.InnerException.Message, Logger.LOGLEVEL.INFO);
                }
                Logger.logDebug(ModuleName, MethodName, "**********Exiting Method**********", Logger.LOGLEVEL.INFO);

                MessageBox.Show(ex.Message);
                throw ex;
            }
            finally
            {
                btnMigrate.Enabled = true;
            }
        }