protected void btnReprocess_Click(object sender, EventArgs e)
        {
            bool blResult = false;

            uploadsCommonBo = new UploadCommonBo();
            xmlPath         = Server.MapPath(ConfigurationManager.AppSettings["xmllookuppath"]).ToString();
            string error                 = "";
            int    countCustCreated      = 0;
            int    countFolioCreated     = 0;
            int    countRejectedRecords  = 0;
            int    processIdReprocessAll = 0;

            //processlogVo = uploadsCommonBo.GetProcessLogInfo(ProcessId);
            //if (processlogVo.FileTypeId == 7)
            //    source = "WP";
            //else if (processlogVo.FileTypeId == 4)
            //    source = "KA";
            //else if (processlogVo.FileTypeId == 2)
            //    source = "CA";
            //else if (processlogVo.FileTypeId == 16)
            //    source = "TN";
            //else if (processlogVo.FileTypeId == 18)
            //    source = "DT";

            // BindGrid
            //if (Request.QueryString["processId"] != null)
            //{
            //    ProcessId = Int32.Parse(Request.QueryString["processId"].ToString());
            //}
            if (Request.QueryString["filetypeid"] != null)
            {
                filetypeId = Int32.Parse(Request.QueryString["filetypeid"].ToString());
            }

            if (Request.QueryString["processId"] != null)
            {
                ProcessId    = Int32.Parse(Request.QueryString["processId"].ToString());
                processlogVo = uploadsCommonBo.GetProcessLogInfo(ProcessId);
                if (processlogVo.FileTypeId == 7)
                {
                    source = "WP";
                }
                else if (processlogVo.FileTypeId == 4)
                {
                    source = "KA";
                }
                else if (processlogVo.FileTypeId == 2)
                {
                    source = "CA";
                }
                else if (processlogVo.FileTypeId == 16)
                {
                    source = "TN";
                }
                else if (processlogVo.FileTypeId == 18)
                {
                    source = "DT";
                }
                else if (processlogVo.FileTypeId == 21)
                {
                    source = "SU";
                }
                if (processlogVo.FileTypeId == 7 || processlogVo.FileTypeId == 4 || processlogVo.FileTypeId == 2 || processlogVo.FileTypeId == 16 || processlogVo.FileTypeId == 18 || processlogVo.FileTypeId == 21)
                {
                    StandardProfileUploadBo standardProfileUploadBo = new StandardProfileUploadBo();
                    //Checks in Profile Staging
                    string packagePath = Server.MapPath("\\UploadPackages\\StandardProfileUploadPackageNew\\StandardProfileUploadPackageNew\\UploadsCommonProfileChecksInProfileStaging.dtsx");
                    bool   karvyProCommonChecksResult = standardProfileUploadBo.StdCommonProfileChecks(ProcessId, adviserId, packagePath, configPath);
                    if (karvyProCommonChecksResult)
                    {
                        // Insert Customer Details into WERP Tables

                        bool stdProCreateCustomerResult = standardProfileUploadBo.StdInsertCustomerDetails(adviserId, ProcessId, rmId, processlogVo.BranchId, xmlPath, out countCustCreated);
                        if (stdProCreateCustomerResult)
                        {
                            //Create new Bank Accounts
                            packagePath = Server.MapPath("\\UploadPackages\\StandardProfileUploadPackageNew\\StandardProfileUploadPackageNew\\UploadCreateNewBankAccount.dtsx");
                            bool stdProCreateBankAccountResult = standardProfileUploadBo.StdCreationOfNewBankAccounts(ProcessId, packagePath, configPath, adviserId);
                            if (stdProCreateBankAccountResult)
                            {
                                processlogVo.IsInsertionToWERPComplete = 1;
                                processlogVo.EndTime                = DateTime.Now;
                                processlogVo.NoOfRejectedRecords    = uploadsCommonBo.GetUploadProfileRejectCount(ProcessId, source);
                                processlogVo.NoOfCustomerInserted   = processlogVo.NoOfCustomerInserted + countCustCreated;
                                processlogVo.NoOfCustomerDuplicates = processlogVo.NoOfTotalRecords - processlogVo.NoOfCustomerInserted - processlogVo.NoOfRejectedRecords;
                                processlogVo.NoOfInputRejects       = uploadsCommonBo.GetUploadProfileInputRejectCount(ProcessId, source);
                                blResult = uploadsCommonBo.UpdateUploadProcessLog(processlogVo);
                                if (blResult)
                                {
                                    bool stdProCommonDeleteResult = standardProfileUploadBo.StdDeleteCommonStaging(ProcessId);
                                }
                            }
                        }
                    }
                }
            }

            else
            {
                DataSet ds = uploadsCommonBo.GetWERPUploadProcessIdForAdviser(adviserId);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    processIdReprocessAll = int.Parse(dr["ProcessId"].ToString());
                    processlogVo          = uploadsCommonBo.GetProcessLogInfo(processIdReprocessAll);
                    if (processlogVo.FileTypeId == 7)
                    {
                        source = "WP";
                    }
                    else if (processlogVo.FileTypeId == 4)
                    {
                        source = "KA";
                    }
                    else if (processlogVo.FileTypeId == 2)
                    {
                        source = "CA";
                    }
                    else if (processlogVo.FileTypeId == 16)
                    {
                        source = "TN";
                    }
                    else if (processlogVo.FileTypeId == 18)
                    {
                        source = "DT";
                    }
                    else if (processlogVo.FileTypeId == 21)
                    {
                        source = "SU";
                    }

                    if (processlogVo.FileTypeId == 7 || processlogVo.FileTypeId == 4 || processlogVo.FileTypeId == 2 || processlogVo.FileTypeId == 16 || processlogVo.FileTypeId == 18 || processlogVo.FileTypeId == 21)
                    {
                        StandardProfileUploadBo standardProfileUploadBo = new StandardProfileUploadBo();
                        //Checks in Profile Staging
                        string packagePath = Server.MapPath("\\UploadPackages\\StandardProfileUploadPackageNew\\StandardProfileUploadPackageNew\\UploadsCommonProfileChecksInProfileStaging.dtsx");
                        bool   karvyProCommonChecksResult = standardProfileUploadBo.StdCommonProfileChecks(processIdReprocessAll, adviserId, packagePath, configPath);
                        if (karvyProCommonChecksResult)
                        {
                            // Insert Customer Details into WERP Tables

                            bool stdProCreateCustomerResult = standardProfileUploadBo.StdInsertCustomerDetails(adviserId, processIdReprocessAll, rmId, processlogVo.BranchId, xmlPath, out countCustCreated);
                            if (stdProCreateCustomerResult)
                            {
                                //Create new Bank Accounts
                                packagePath = Server.MapPath("\\UploadPackages\\StandardProfileUploadPackageNew\\StandardProfileUploadPackageNew\\UploadCreateNewBankAccount.dtsx");
                                bool stdProCreateBankAccountResult = standardProfileUploadBo.StdCreationOfNewBankAccounts(processIdReprocessAll, packagePath, configPath, adviserId);
                                if (stdProCreateBankAccountResult)
                                {
                                    processlogVo.IsInsertionToWERPComplete = 1;
                                    processlogVo.EndTime                = DateTime.Now;
                                    processlogVo.NoOfRejectedRecords    = uploadsCommonBo.GetUploadProfileRejectCount(processIdReprocessAll, source);
                                    processlogVo.NoOfCustomerInserted   = processlogVo.NoOfCustomerInserted + countCustCreated;
                                    processlogVo.NoOfCustomerDuplicates = processlogVo.NoOfTotalRecords - processlogVo.NoOfCustomerInserted - processlogVo.NoOfRejectedRecords;
                                    processlogVo.NoOfInputRejects       = uploadsCommonBo.GetUploadProfileInputRejectCount(processIdReprocessAll, source);
                                    blResult = uploadsCommonBo.UpdateUploadProcessLog(processlogVo);
                                    if (blResult)
                                    {
                                        bool stdProCommonDeleteResult = standardProfileUploadBo.StdDeleteCommonStaging(processIdReprocessAll);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (blResult == false)
            {
                error = error + "Error when reprocessing for the processid:" + processIdReprocessAll + ";";
            }
            if (blResult)
            {
                // Success Message
                //trErrorMessage.Visible = true;
                //lblError.Text = "Reprocess Done Successfully!";
                msgReprocessComplete.Visible = true;
            }
            else
            {
                // Failure Message
                msgReprocessincomplete.Visible = true;
            }

            BindWerpProfileGrid(ProcessId);
        }