//Fifth Phase: Move KARVY customer details to customer table
        public bool KARVYInsertCustomerDetails(int adviserId, int processId, int rmId, out int countCustCreated, out int countFolioCreated)
        {
            bool IsProcessComplete = false;
            List <KarvyUploadsVo> karvyNewCustomerList = new List <KarvyUploadsVo>();
            Nullable <DateTime>   dt = new DateTime();
            KarvyUploadsVo        karvyUploadsVo = new KarvyUploadsVo();
            string resIsdCode = "", resStdCode = "", resPhoneNum = "";
            string offIsdCode = "", offStdCode = "", offPhoneNum = "";
            string resFaxIsdCode = "", resFaxStdCode = "", resFaxNum = "";
            string offFaxIsdCode = "", offFaxStdCode = "", offFaxNum = "";
            int    lenPhoneNum, lenFaxNum;

            countCustCreated  = 0;
            countFolioCreated = 0;
            DataSet   getNewFoliosDs = new DataSet();
            DataTable getNewFoliosDt = new DataTable();

            userId = advisorStaffBo.GetUserId(rmId);

            try
            {
                karvyNewCustomerList = GetKarvyProfNewCustomers(processId);
                for (int i = 0; i < karvyNewCustomerList.Count; i++)
                {
                    customerVo     = new CustomerVo();
                    userVo         = new UserVo();
                    karvyUploadsVo = new KarvyUploadsVo();

                    karvyUploadsVo    = karvyNewCustomerList[i];
                    userVo.FirstName  = "";
                    userVo.MiddleName = "";
                    userVo.LastName   = karvyUploadsVo.InvestorName;
                    //userVo.Password = id.Next(10000, 99999).ToString();
                    userVo.Email = karvyUploadsVo.Email;
                    //userVo.LoginId = karvyUploadsVo.Email;
                    userVo.UserType = "Customer";

                    //userId = userBo.CreateUser(userVo);

                    customerVo.ProcessId        = processId;
                    customerVo.UserId           = userId;
                    customerVo.RmId             = rmId;
                    customerVo.Adr1City         = karvyUploadsVo.City;
                    customerVo.Adr1Country      = karvyUploadsVo.Country;
                    customerVo.Adr1Line1        = karvyUploadsVo.Address1;
                    customerVo.Adr1Line2        = karvyUploadsVo.Address2;
                    customerVo.Adr1Line3        = karvyUploadsVo.Address3;
                    customerVo.Adr1PinCode      = Int32.Parse(karvyUploadsVo.Pincode);
                    customerVo.Adr2PinCode      = 0;
                    customerVo.OfcAdrPinCode    = 0;
                    customerVo.Adr1State        = karvyUploadsVo.State;
                    customerVo.CommencementDate = DateTime.Parse(dt.ToString());
                    if (karvyUploadsVo.DateofBirth == "")
                    {
                        customerVo.Dob = DateTime.Parse(dt.ToString());
                    }
                    else
                    {
                        customerVo.Dob = DateTime.Parse(karvyUploadsVo.DateofBirth);
                    }
                    customerVo.Email      = karvyUploadsVo.Email;
                    customerVo.FirstName  = karvyUploadsVo.FirstName;
                    customerVo.MiddleName = karvyUploadsVo.MiddleName;
                    customerVo.LastName   = karvyUploadsVo.InvestorName;
                    customerVo.LoginId    = karvyUploadsVo.Email;
                    if (karvyUploadsVo.Mobile == "")
                    {
                        customerVo.Mobile1 = 0;
                    }
                    else
                    {
                        customerVo.Mobile1 = Int64.Parse(karvyUploadsVo.Mobile);
                    }


                    lenFaxNum = karvyUploadsVo.FaxResidence.Length;
                    if (lenFaxNum >= 8)
                    {
                        resFaxNum = karvyUploadsVo.FaxResidence.Substring(lenFaxNum - 8, 8);
                        if (lenFaxNum >= 11)
                        {
                            resFaxStdCode = karvyUploadsVo.FaxResidence.Substring(lenFaxNum - 11, 3);
                            if (lenFaxNum >= 12)
                            {
                                resFaxIsdCode = karvyUploadsVo.FaxResidence.Substring(0, lenFaxNum - 11);
                            }
                        }
                        else
                        {
                            resFaxStdCode = karvyUploadsVo.FaxResidence.Substring(0, lenFaxNum - 8);
                        }
                    }
                    else
                    {
                        resFaxNum = karvyUploadsVo.FaxResidence;
                    }
                    if (resFaxIsdCode != "")
                    {
                        customerVo.ISDFax = Int32.Parse(resFaxIsdCode);
                    }
                    else
                    {
                        customerVo.ISDFax = 0;
                    }
                    if (resFaxStdCode != "")
                    {
                        customerVo.STDFax = Int32.Parse(resFaxStdCode);
                    }
                    else
                    {
                        customerVo.STDFax = 0;
                    }
                    if (resFaxNum != "")
                    {
                        customerVo.Fax = Int32.Parse(resFaxNum);
                    }
                    else
                    {
                        customerVo.Fax = 0;
                    }



                    lenFaxNum = karvyUploadsVo.FaxOffice.Length;
                    if (lenFaxNum >= 8)
                    {
                        offFaxNum = karvyUploadsVo.FaxOffice.Substring(lenFaxNum - 8, 8);
                        if (lenFaxNum >= 11)
                        {
                            offFaxStdCode = karvyUploadsVo.FaxOffice.Substring(lenFaxNum - 11, 3);
                            if (lenFaxNum >= 12)
                            {
                                offFaxIsdCode = karvyUploadsVo.FaxOffice.Substring(0, lenFaxNum - 11);
                            }
                        }
                        else
                        {
                            offFaxStdCode = karvyUploadsVo.FaxOffice.Substring(0, lenFaxNum - 8);
                        }
                    }
                    else
                    {
                        offFaxNum = karvyUploadsVo.FaxOffice;
                    }
                    if (offFaxIsdCode != "")
                    {
                        customerVo.OfcISDFax = Int32.Parse(offFaxIsdCode);
                    }
                    else
                    {
                        customerVo.OfcISDFax = 0;
                    }
                    if (offFaxStdCode != "")
                    {
                        customerVo.OfcSTDFax = Int32.Parse(offFaxStdCode);
                    }
                    else
                    {
                        customerVo.OfcSTDFax = 0;
                    }
                    if (offFaxNum != "")
                    {
                        customerVo.OfcFax = Int32.Parse(offFaxNum);
                    }
                    else
                    {
                        customerVo.OfcFax = 0;
                    }



                    lenPhoneNum = karvyUploadsVo.PhoneOffice.Length;
                    if (lenPhoneNum >= 8)
                    {
                        offPhoneNum = karvyUploadsVo.PhoneOffice.Substring(lenPhoneNum - 8, 8);
                        if (lenPhoneNum >= 11)
                        {
                            offStdCode = karvyUploadsVo.PhoneOffice.Substring(lenPhoneNum - 11, 3);
                            if (lenPhoneNum >= 12)
                            {
                                offIsdCode = karvyUploadsVo.PhoneOffice.Substring(0, lenPhoneNum - 11);
                            }
                        }
                        else
                        {
                            offStdCode = karvyUploadsVo.PhoneOffice.Substring(0, lenPhoneNum - 8);
                        }
                    }
                    else
                    {
                        offPhoneNum = karvyUploadsVo.PhoneOffice;
                    }
                    if (offIsdCode != "")
                    {
                        customerVo.OfcISDCode = Int32.Parse(offIsdCode);
                    }
                    else
                    {
                        customerVo.OfcISDCode = 0;
                    }
                    if (offStdCode != "")
                    {
                        customerVo.OfcSTDCode = Int32.Parse(offStdCode);
                    }
                    else
                    {
                        customerVo.OfcSTDCode = 0;
                    }
                    if (offPhoneNum != "")
                    {
                        customerVo.OfcPhoneNum = Int32.Parse(offPhoneNum);
                    }
                    else
                    {
                        customerVo.OfcPhoneNum = 0;
                    }



                    lenPhoneNum = karvyUploadsVo.PhoneResidence.Length;
                    if (lenPhoneNum >= 8)
                    {
                        resPhoneNum = karvyUploadsVo.PhoneResidence.Substring(lenPhoneNum - 8, 8);
                        if (lenPhoneNum >= 11)
                        {
                            resStdCode = karvyUploadsVo.PhoneResidence.Substring(lenPhoneNum - 11, 3);
                            if (lenPhoneNum >= 12)
                            {
                                resIsdCode = karvyUploadsVo.PhoneResidence.Substring(0, lenPhoneNum - 11);
                            }
                        }
                        else
                        {
                            resStdCode = karvyUploadsVo.PhoneResidence.Substring(0, lenPhoneNum - 8);
                        }
                    }
                    else
                    {
                        resPhoneNum = karvyUploadsVo.PhoneResidence;
                    }
                    if (resIsdCode != "")
                    {
                        customerVo.ResISDCode = Int32.Parse(resIsdCode);
                    }
                    else
                    {
                        customerVo.ResISDCode = 0;
                    }
                    if (resStdCode != "")
                    {
                        customerVo.ResSTDCode = Int32.Parse(resStdCode);
                    }
                    else
                    {
                        customerVo.ResSTDCode = 0;
                    }
                    if (resPhoneNum != "")
                    {
                        customerVo.ResPhoneNum = Int32.Parse(resPhoneNum);
                    }
                    else
                    {
                        customerVo.ResPhoneNum = 0;
                    }



                    customerVo.Type             = karvyUploadsVo.TypeCode;
                    customerVo.SubType          = karvyUploadsVo.SubTypeCode;
                    customerVo.Occupation       = karvyUploadsVo.OccCode;
                    customerVo.PANNum           = karvyUploadsVo.PANNumber;
                    customerVo.Password         = id.Next(10000, 99999).ToString();
                    customerVo.ProfilingDate    = DateTime.Today;
                    customerVo.RBIApprovalDate  = DateTime.Parse(dt.ToString());
                    customerVo.RegistrationDate = DateTime.Parse(dt.ToString());
                    customerVo.CommencementDate = DateTime.Parse(dt.ToString());
                    //customerId2 = customerBo.CreateCustomer(customerVo, rmId, userId);

                    //customerPortfolioVo.CustomerId = customerId2;
                    customerPortfolioVo.IsMainPortfolio   = 1;
                    customerPortfolioVo.PortfolioTypeCode = "RGL";
                    //PortfolioBo.CreateCustomerPortfolio(customerPortfolioVo, userId);

                    customerBo.CreateCompleteCustomer(customerVo, userVo, customerPortfolioVo, userId);

                    countCustCreated++;
                }
                UpdateKarvyProfileStagingIsCustomerNew(adviserId, processId);

                //*****New Folios Upload from CAMS*****
                getNewFoliosDs = GetKarvyProfileNewFolios(processId);
                getNewFoliosDt = getNewFoliosDs.Tables[0];
                foreach (DataRow dr in getNewFoliosDt.Rows)
                {
                    customerAccountsVo.AccountNum  = dr["CMFKXPS_Folio"].ToString();
                    customerAccountsVo.PortfolioId = Int32.Parse(dr["CP_PortfolioId"].ToString());
                    customerAccountsVo.AssetClass  = "MF";
                    customerAccountsVo.AMCCode     = Int32.Parse(dr["PA_AMCCode"].ToString());
                    customerAccountBo.CreateCustomerMFAccount(customerAccountsVo, userId);
                    countFolioCreated++;
                }
                UpdateKarvyProfileStagingIsFolioNew(processId);
                IsProcessComplete = true;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "KarvyUploadsBo.cs:KARVYInsertCustomerDetails()");

                object[] objects = new object[3];
                objects[0] = adviserId;
                objects[1] = processId;
                objects[2] = rmId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(IsProcessComplete);
        }
        //Fifth Phase: Move WerpMF customer details to customer table
        public bool WerpMFInsertCustomerDetails(int adviserId, int processId, int rmId, out int countCustCreated, out int countFolioCreated)
        {
            bool IsProcessComplete = false;
            List <WerpMFUploadsVo> werpMFNewCustomerList = new List <WerpMFUploadsVo>();
            Nullable <DateTime>    dt = new DateTime();
            WerpMFUploadsVo        werpMFUploadsVo = new WerpMFUploadsVo();
            string resIsdCode = "", resStdCode = "", resPhoneNum = "", offIsdCode = "", offStdCode = "", offPhoneNum = "";
            string resFaxIsdCode = "", resFaxStdCode = "", resFaxNum = "", offFaxIsdCode = "", offFaxStdCode = "", offFaxNum = "";
            int    lenPhoneNum;
            int    lenFaxNum;

            countCustCreated  = 0;
            countFolioCreated = 0;
            DataSet   getNewFoliosDs = new DataSet();
            DataTable getNewFoliosDt = new DataTable();

            userId = advisorstaffBo.GetUserId(rmId);

            try
            {
                werpMFNewCustomerList = GetWerpMFProfNewCustomers(processId);
                for (int i = 0; i < werpMFNewCustomerList.Count; i++)
                {
                    customerVo      = new CustomerVo();
                    userVo          = new UserVo();
                    werpMFUploadsVo = new WerpMFUploadsVo();

                    werpMFUploadsVo   = werpMFNewCustomerList[i];
                    userVo.FirstName  = werpMFUploadsVo.FirstName;
                    userVo.MiddleName = werpMFUploadsVo.MiddleName;
                    userVo.LastName   = werpMFUploadsVo.LastName;
                    userVo.Password   = id.Next(10000, 99999).ToString();
                    userVo.Email      = werpMFUploadsVo.Email;
                    userVo.LoginId    = werpMFUploadsVo.Email;
                    userVo.UserType   = "Customer";

                    //userId = userBo.CreateUser(userVo);

                    customerVo.UserId = userId;
                    customerVo.RmId   = rmId;

                    customerVo.FirstName  = werpMFUploadsVo.FirstName;
                    customerVo.MiddleName = werpMFUploadsVo.MiddleName;
                    customerVo.LastName   = werpMFUploadsVo.LastName;
                    customerVo.Gender     = werpMFUploadsVo.Gender;
                    if (werpMFUploadsVo.DOB == "")
                    {
                        customerVo.Dob = DateTime.Parse(dt.ToString());
                    }
                    else
                    {
                        customerVo.Dob = DateTime.Parse(werpMFUploadsVo.DOB);
                    }
                    if (werpMFUploadsVo.Type != "")
                    {
                        customerVo.Type = werpMFUploadsVo.Type;
                    }
                    if (werpMFUploadsVo.SubType != "")
                    {
                        customerVo.SubType = werpMFUploadsVo.SubType;
                    }
                    customerVo.Salutation = werpMFUploadsVo.Salutation;
                    customerVo.PANNum     = werpMFUploadsVo.PanNumber;
                    customerVo.Adr1Line1  = werpMFUploadsVo.Address1;
                    customerVo.Adr1Line2  = werpMFUploadsVo.Address2;
                    customerVo.Adr1Line3  = werpMFUploadsVo.Address3;
                    if (werpMFUploadsVo.Pincode == "")
                    {
                        customerVo.Adr1PinCode = 0;
                    }
                    else
                    {
                        customerVo.Adr1PinCode = Int32.Parse(werpMFUploadsVo.Pincode);
                    }
                    customerVo.Adr1City    = werpMFUploadsVo.City;
                    customerVo.Adr1State   = werpMFUploadsVo.State;
                    customerVo.Adr1Country = werpMFUploadsVo.Country;
                    customerVo.Adr2Line1   = werpMFUploadsVo.Address2Line1;
                    customerVo.Adr2Line2   = werpMFUploadsVo.Address2Line2;
                    customerVo.Adr2Line3   = werpMFUploadsVo.Address2Line3;
                    if (werpMFUploadsVo.Address2Pincode == "")
                    {
                        customerVo.Adr2PinCode = 0;
                    }
                    else
                    {
                        customerVo.Adr2PinCode = Int32.Parse(werpMFUploadsVo.Address2Pincode);
                    }
                    customerVo.Adr2City    = werpMFUploadsVo.Address2City;
                    customerVo.Adr2Country = werpMFUploadsVo.Address2Country;
                    customerVo.Adr2State   = werpMFUploadsVo.Address2State;
                    customerVo.Email       = werpMFUploadsVo.Email;
                    customerVo.AltEmail    = werpMFUploadsVo.AltEmail;
                    if (werpMFUploadsVo.Mobile1 == "")
                    {
                        customerVo.Mobile1 = 0;
                    }
                    else
                    {
                        customerVo.Mobile1 = Int32.Parse(werpMFUploadsVo.Mobile1);
                    }
                    if (werpMFUploadsVo.Mobile2 == "")
                    {
                        customerVo.Mobile2 = 0;
                    }
                    else
                    {
                        customerVo.Mobile2 = Int32.Parse(werpMFUploadsVo.Mobile2);
                    }
                    if (werpMFUploadsVo.Occupation != "")
                    {
                        customerVo.Occupation = werpMFUploadsVo.Occupation;
                    }
                    if (werpMFUploadsVo.Qualification != "")
                    {
                        customerVo.Qualification = werpMFUploadsVo.Qualification;
                    }
                    //customerVo.MarriageDate
                    if (werpMFUploadsVo.MaritalStatus != "")
                    {
                        customerVo.MaritalStatus = werpMFUploadsVo.MaritalStatus;
                    }
                    if (werpMFUploadsVo.Nationality != "")
                    {
                        customerVo.Nationality = werpMFUploadsVo.Nationality;
                    }
                    customerVo.RBIRefNum = werpMFUploadsVo.RBIRefNum;
                    if (werpMFUploadsVo.RBIApprovalDate == "")
                    {
                        customerVo.RBIApprovalDate = DateTime.Parse(dt.ToString());
                    }
                    else
                    {
                        customerVo.RBIApprovalDate = DateTime.Parse(werpMFUploadsVo.RBIApprovalDate.ToString());
                    }
                    customerVo.CompanyName = werpMFUploadsVo.CompanyName;
                    customerVo.OfcAdrLine1 = werpMFUploadsVo.OfcAddress1;
                    customerVo.OfcAdrLine2 = werpMFUploadsVo.OfcAddress2;
                    customerVo.OfcAdrLine3 = werpMFUploadsVo.OfcAddress3;
                    if (werpMFUploadsVo.OfcAddressPincode == "")
                    {
                        customerVo.OfcAdrPinCode = 0;
                    }
                    else
                    {
                        customerVo.OfcAdrPinCode = Int32.Parse(werpMFUploadsVo.OfcAddressPincode);
                    }
                    customerVo.OfcAdrState   = werpMFUploadsVo.State;
                    customerVo.OfcAdrCity    = werpMFUploadsVo.OfcAddressCity;
                    customerVo.OfcAdrCountry = werpMFUploadsVo.OfcAddressCountry;
                    if (werpMFUploadsVo.RegistrationDate == "")
                    {
                        customerVo.RegistrationDate = DateTime.Parse(dt.ToString());
                    }
                    else
                    {
                        customerVo.RegistrationDate = DateTime.Parse(werpMFUploadsVo.RegistrationDate.ToString());
                    }
                    if (werpMFUploadsVo.CommencementDate == "")
                    {
                        customerVo.CommencementDate = DateTime.Parse(dt.ToString());
                    }
                    else
                    {
                        customerVo.CommencementDate = DateTime.Parse(werpMFUploadsVo.CommencementDate.ToString());
                    }
                    customerVo.RegistrationPlace = werpMFUploadsVo.RegistrationPlace;
                    customerVo.RegistrationNum   = werpMFUploadsVo.ResPhoneNum;
                    customerVo.CompanyWebsite    = werpMFUploadsVo.CompanyWebsite;
                    customerVo.LoginId           = werpMFUploadsVo.Email;
                    customerVo.Password          = id.Next(10000, 99999).ToString();
                    //**************************************************************************
                    //Office phone number
                    lenPhoneNum = werpMFUploadsVo.OfcPhoneNum.Length;
                    if (lenPhoneNum >= 8)
                    {
                        offPhoneNum = werpMFUploadsVo.OfcPhoneNum.Substring(lenPhoneNum - 8, 8);
                        if (lenPhoneNum >= 11)
                        {
                            offStdCode = werpMFUploadsVo.OfcPhoneNum.Substring(lenPhoneNum - 11, 3);
                            if (lenPhoneNum >= 12)
                            {
                                offIsdCode = werpMFUploadsVo.OfcPhoneNum.Substring(0, lenPhoneNum - 11);
                            }
                        }
                        else
                        {
                            offStdCode = werpMFUploadsVo.OfcPhoneNum.Substring(0, lenPhoneNum - 8);
                        }
                    }
                    else
                    {
                        offPhoneNum = werpMFUploadsVo.OfcPhoneNum;
                    }
                    if (offIsdCode != "")
                    {
                        customerVo.OfcISDCode = Int32.Parse(offIsdCode);
                    }
                    else
                    {
                        customerVo.OfcISDCode = 0;
                    }
                    if (offStdCode != "")
                    {
                        customerVo.OfcSTDCode = Int32.Parse(offStdCode);
                    }
                    else
                    {
                        customerVo.OfcSTDCode = 0;
                    }
                    if (offPhoneNum != "")
                    {
                        customerVo.OfcPhoneNum = Int32.Parse(offPhoneNum);
                    }
                    else
                    {
                        customerVo.OfcPhoneNum = 0;
                    }

                    //**************************************************************************
                    //residence phone number

                    lenPhoneNum = werpMFUploadsVo.ResPhoneNum.Length;
                    if (lenPhoneNum >= 8)
                    {
                        resPhoneNum = werpMFUploadsVo.ResPhoneNum.Substring(lenPhoneNum - 8, 8);
                        if (lenPhoneNum >= 11)
                        {
                            resStdCode = werpMFUploadsVo.ResPhoneNum.Substring(lenPhoneNum - 11, 3);
                            if (lenPhoneNum >= 12)
                            {
                                resIsdCode = werpMFUploadsVo.ResPhoneNum.Substring(0, lenPhoneNum - 11);
                            }
                        }
                        else
                        {
                            resStdCode = werpMFUploadsVo.ResPhoneNum.Substring(0, lenPhoneNum - 8);
                        }
                    }
                    else
                    {
                        resPhoneNum = werpMFUploadsVo.ResPhoneNum;
                    }
                    if (resIsdCode != "")
                    {
                        customerVo.ResISDCode = Int32.Parse(resIsdCode);
                    }
                    else
                    {
                        customerVo.ResISDCode = 0;
                    }
                    if (resStdCode != "")
                    {
                        customerVo.ResSTDCode = Int32.Parse(resStdCode);
                    }
                    else
                    {
                        customerVo.ResSTDCode = 0;
                    }
                    if (resPhoneNum != "")
                    {
                        customerVo.ResPhoneNum = Int32.Parse(resPhoneNum);
                    }
                    else
                    {
                        customerVo.ResPhoneNum = 0;
                    }

                    //**************************************************************************

                    //**************************************************************************
                    //Fax residence
                    lenFaxNum = werpMFUploadsVo.Fax.Length;
                    if (lenFaxNum >= 8)
                    {
                        resFaxNum = werpMFUploadsVo.Fax.Substring(lenFaxNum - 8, 8);
                        if (lenFaxNum >= 11)
                        {
                            resFaxStdCode = werpMFUploadsVo.Fax.Substring(lenFaxNum - 11, 3);
                            if (lenFaxNum >= 12)
                            {
                                resFaxIsdCode = werpMFUploadsVo.Fax.Substring(0, lenFaxNum - 11);
                            }
                        }
                        else
                        {
                            resFaxStdCode = werpMFUploadsVo.Fax.Substring(0, lenFaxNum - 8);
                        }
                    }
                    else
                    {
                        resFaxNum = werpMFUploadsVo.Fax;
                    }
                    if (resFaxIsdCode != "")
                    {
                        customerVo.ISDFax = Int32.Parse(resFaxIsdCode);
                    }
                    else
                    {
                        customerVo.ISDFax = 0;
                    }
                    if (resFaxStdCode != "")
                    {
                        customerVo.STDFax = Int32.Parse(resFaxStdCode);
                    }
                    else
                    {
                        customerVo.STDFax = 0;
                    }
                    if (resFaxNum != "")
                    {
                        customerVo.Fax = Int32.Parse(resFaxNum);
                    }
                    else
                    {
                        customerVo.Fax = 0;
                    }
                    //**************************************************************************
                    //Fax Office
                    lenFaxNum = werpMFUploadsVo.OfcFax.Length;
                    if (lenFaxNum >= 8)
                    {
                        offFaxNum = werpMFUploadsVo.OfcFax.Substring(lenFaxNum - 8, 8);
                        if (lenFaxNum >= 11)
                        {
                            offFaxStdCode = werpMFUploadsVo.OfcFax.Substring(lenFaxNum - 11, 3);
                            if (lenFaxNum >= 12)
                            {
                                offFaxIsdCode = werpMFUploadsVo.OfcFax.Substring(0, lenFaxNum - 11);
                            }
                        }
                        else
                        {
                            offFaxStdCode = werpMFUploadsVo.OfcFax.Substring(0, lenFaxNum - 8);
                        }
                    }
                    else
                    {
                        offFaxNum = werpMFUploadsVo.OfcFax;
                    }
                    if (offFaxIsdCode != "")
                    {
                        customerVo.OfcISDFax = Int32.Parse(offFaxIsdCode);
                    }
                    else
                    {
                        customerVo.OfcISDFax = 0;
                    }
                    if (offFaxStdCode != "")
                    {
                        customerVo.OfcSTDFax = Int32.Parse(offFaxStdCode);
                    }
                    else
                    {
                        customerVo.OfcSTDFax = 0;
                    }
                    if (offFaxNum != "")
                    {
                        customerVo.OfcFax = Int32.Parse(offFaxNum);
                    }
                    else
                    {
                        customerVo.OfcFax = 0;
                    }


                    //customerId2 = customerBo.CreateCustomer(customerVo, rmId, userId);

                    //customerPortfolioVo.CustomerId = customerId2;
                    customerPortfolioVo.IsMainPortfolio   = 1;
                    customerPortfolioVo.PortfolioTypeCode = "RGL";
                    customerPortfolioVo.PortfolioName     = "MyPortfolio";
                    //PortfolioBo.CreateCustomerPortfolio(customerPortfolioVo, userId);

                    customerBo.CreateCompleteCustomer(customerVo, userVo, customerPortfolioVo, userId);

                    countCustCreated++;
                }
                UpdateWerpMFProfileStagingIsCustomerNew(adviserId, processId);

                //*****New Folios Upload from CAMS*****
                getNewFoliosDs = GetWerpMFProfileNewFolios(processId);
                getNewFoliosDt = getNewFoliosDs.Tables[0];
                foreach (DataRow dr in getNewFoliosDt.Rows)
                {
                    customerAccountsVo.AccountNum  = dr["CMFXPS_FolioNum"].ToString();
                    customerAccountsVo.PortfolioId = Int32.Parse(dr["CP_PortfolioId"].ToString());
                    customerAccountsVo.AssetClass  = "MF";
                    customerAccountsVo.AMCCode     = Int32.Parse(dr["PA_AMCCode"].ToString());
                    customerAccountBo.CreateCustomerMFAccount(customerAccountsVo, userId);

                    countFolioCreated++;
                }
                UpdateWerpMFProfileStagingIsFolioNew(processId);
                IsProcessComplete = true;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "WerpMFUploadsBo.cs:WerpMFInsertCustomerDetails()");

                object[] objects = new object[3];
                objects[0] = adviserId;
                objects[1] = processId;
                objects[2] = rmId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(IsProcessComplete);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                customerAccountsVo.AccountNum  = txtFolioNumber.Text;
                customerAccountsVo.AssetClass  = "MF";
                customerAccountsVo.CustomerId  = customerVo.CustomerId;
                customerAccountsVo.PortfolioId = portfolioId;
                if (rbtnNo.Checked)
                {
                    customerAccountsVo.IsJointHolding = 0;
                }
                else
                {
                    customerAccountsVo.IsJointHolding = 1;
                }
                if (ddlModeOfHolding.SelectedValue != "Select Mode of Holding")
                {
                    customerAccountsVo.ModeOfHolding = ddlModeOfHolding.SelectedItem.Value.ToString();
                }
                if (txtAccountDate.Text != "")
                {
                    customerAccountsVo.AccountOpeningDate = DateTime.Parse(txtAccountDate.Text.Trim());
                }
                customerAccountsVo.AMCCode = int.Parse(ddlProductAmc.SelectedItem.Value.ToString());
                accountId = customerAccountBo.CreateCustomerMFAccount(customerAccountsVo, userVo.UserId);

                customerAccountsVo.AccountId            = accountId;
                customerAccountAssociationVo.AccountId  = accountId;
                customerAccountAssociationVo.CustomerId = customerVo.CustomerId;
                foreach (GridViewRow gvr in this.gvNominees.Rows)
                {
                    if (((CheckBox)gvr.FindControl("chkId0")).Checked == true)
                    {
                        customerAccountAssociationVo.AssociationId   = int.Parse(gvNominees.DataKeys[gvr.RowIndex].Values[1].ToString());
                        customerAccountAssociationVo.AssociationType = "Nominee";
                        customerAccountBo.CreateMFAccountAssociation(customerAccountAssociationVo, userVo.UserId);
                    }
                }
                if (rbtnYes.Checked)
                {
                    foreach (GridViewRow gvr in this.gvJointHoldersList.Rows)
                    {
                        if (((CheckBox)gvr.FindControl("chkId")).Checked == true)
                        {
                            customerAccountAssociationVo.AssociationId   = int.Parse(gvJointHoldersList.DataKeys[gvr.RowIndex].Values[0].ToString());
                            customerAccountAssociationVo.AssociationType = "Joint Holder";
                            customerAccountBo.CreateMFAccountAssociation(customerAccountAssociationVo, userVo.UserId);
                        }
                    }
                }

                Session[SessionContents.CustomerMFAccount] = customerAccountsVo;
                Session[SessionContents.PortfolioId]       = ddlPortfolio.SelectedValue.ToString();

                if (Request.QueryString["FromPage"] == "MFManualSingleTran")
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('MFManualSingleTran','?prevPage=CustomerMFAccountAdd');", true);
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('CustomerMFFolioView','none');", true);
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }

            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "CustomerMFAccountAdd.ascx:rbtnYes_CheckedChanged()");
                object[] objects = new object[5];
                objects[0]   = customerAccountAssociationVo;
                objects[1]   = customerAccountsVo;
                objects[2]   = userVo;
                objects[3]   = customerVo;
                objects[4]   = portfolioId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }