//private void GetBranch()
        //{
        //    DataTable dt = new DataTable();
        //    BranchBLL branchBll = new BranchBLL();
        //    try
        //    {
        //        dt = branchBll.GetBranchList();
        //        if (dt.Rows.Count > 0)
        //        {
        //            BranchDropDownList.DataSource = dt;
        //            BranchDropDownList.DataValueField = "BranchId";
        //            BranchDropDownList.DataTextField = "Name";
        //            BranchDropDownList.DataBind();
        //            BranchDropDownList.Items.Insert(0, "----------Select----------");
        //            //    BranchDropDownList.SelectedIndex = 0;
        //            BranchDropDownList.SelectedValue = (string)LumexSessionManager.Get("UserBranchId");
        //        }
        //        dt.Clear();
        //    }
        //    catch (Exception ex)
        //    {
        //        string message = ex.Message;
        //        if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
        //        MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
        //    }
        //}
        protected void GetUserList()
        {
            UserBLL user = new UserBLL();

            try
            {
                DataTable dt = user.GetUserListByBruchId(LumexSessionManager.Get("UserBranchId").ToString());
                userListGridView.DataSource = dt;
                userListGridView.DataBind();

                if (dt.Rows.Count < 1)
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
                GridviewHeadStyle();
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                user = null;
            }
        }
        public static bool ValidateUser(UserBLL user, LumexDBPlayer db)
        {
            bool isValid = false;

            try
            {
                db.AddParameters("@UserId", user.UserId);

                DataTable dt = db.ExecuteDataTable("GET_USER_PASS_ID_AT_LOGIN", true);

                DataTableReader dtr = dt.CreateDataReader();

                if (dtr.Read())
                {
                    if (ProtectPassword(user.Password) == dtr["Password"].ToString())
                    {
                        isValid = true;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                user = null;
            }

            return isValid;
        }
        protected void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                UserBLL usrbll = new UserBLL();
                //string userID = usrbll.UserId = hdnfldUserID.Value;
                //usrbll.Password = newPasswordTextBox.Text;
                bool status = usrbll.UpdateUserPassword(hdnfldUserID.Value, newPasswordTextBox.Text);
                if (status)
                {

                    //UserActivityBLL userActivityBll = new UserActivityBLL();
                    //string activity = (string)LumexSessionManager.Get("ActiveUserId") + " Changed Password.";
                    //string AffectedUser = (string)LumexSessionManager.Get("ActiveUserId");
                    //userActivityBll.AddIntoUserActivity(activity, AffectedUser);

                    string message = " <span class='actionTopic'>" + "Your Password is Changed Successfully" + "</span>.";
                    MyAlertBox("var callbackOk = function () { window.location = \"/login.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                }

            }
            catch (Exception ex)
            {

                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");

            }
        }
        protected void btnIsDelete_Click(object sender, EventArgs e)
        {
            bool status = false;

            try
            {
                LinkButton lnkBtn = (LinkButton)sender;
                GridViewRow row = (GridViewRow)lnkBtn.NamingContainer;
                string userId = userListGridView.Rows[row.RowIndex].Cells[0].Text.ToString();
                UserBLL userbll = new UserBLL();
                userbll.DeleteUser(userId);
                status = true;
                if (status)
                {
                    GetUserList();

                }
            }
            catch (Exception ex)
            {

                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
        }
        protected void verifyButton_Click(object sender, EventArgs e)
        {
            UserBLL usrbll = new UserBLL();
            string varifyCode = hdnfldVarifiCode.Value.Replace(" ", "+");
            if ((!string.IsNullOrEmpty(varifyCode)))
            {
                if (verificationCodeTextBox.Text.Trim() == dataEncryptbll.DecryptRijndael(varifyCode, dataEncryptbll.addforvarifycore))
                {
                    varificationSection.Visible = false;
                    changePasswordSection.Visible = true;

                    // UserActivityBLL userActivityBll = new UserActivityBLL();
                    //string activity = (string)LumexSessionManager.Get("ActiveUserId") + " is Varified.";
                    //string AffectedUser = (string)LumexSessionManager.Get("ActiveUserId");
                    //userActivityBll.AddIntoUserActivity(activity, AffectedUser);

                    string message = " <span class='actionTopic'>" + "Your are Varified Successfully. Please Set Password to login." + "</span>.";
                    MyAlertBox("var callbackOk = function () { window.location = \"\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", \"\");");

                }
                else
                {
                    string message = " <span class='actionTopic'>" + "Your Varification Code is Incorrect or Expire!!" + "</span>.";
                    MyAlertBox("var callbackOk = function () { window.location = \"\"; }; ErrorAlert(\"" + "Process Succeed" + "\", \"" + message + "\", \"\");");

                }

            }
        }
        private void ViewUserInfo()
        {
            UserBLL aUser = new UserBLL();
            try
            {

                //if (Session["UserIdForView"] == null)
                //{
                //    aUser.UserId = LumexSessionManager.Get("ActiveUserId").ToString();
                //}
                //else
                //{
                //    aUser.UserId = LumexSessionManager.Get("UserIdForView").ToString();
                //}
                aUser.UserId = LumexSessionManager.Get("ActiveUserId").ToString();
                lblUserId.Text = aUser.UserId;
                LumexSessionManager.Add("UserIdForUpdate", lblUserId.Text);
                DataTable dt = new DataTable();
                dt = aUser.GetUserInfoByIdForView(aUser.UserId);

                if (dt.Rows.Count > 0)
                {
                    lvlName.Text = dt.Rows[0]["FirstName"].ToString() + dt.Rows[0]["LastName"].ToString();
                    lvlEmail.Text = dt.Rows[0]["Email"].ToString();
                    lvlMobile.Text = dt.Rows[0]["MobileNo"].ToString();
                    lvlLeft.Text = dt.Rows[0]["TotalLeft"].ToString() + " [" + dt.Rows[0]["LeftCount"].ToString() + "]";
                    lvlRight.Text = dt.Rows[0]["TotalRight"].ToString() + " [" + dt.Rows[0]["RightCount"].ToString() + "]";

                    LumexSessionManager.Remove("UserIdForView");
                    if (dt.Rows[0]["IsActive"].ToString() == "Yes")
                    {

                        btnActive.Visible = false;
                        lvlIsActive.Visible = false;

                        UserAccountBLL userAccount = new UserAccountBLL();

                        dt = userAccount.GetUserActivationInfoById(lblUserId.Text);
                        lblStakeName.Text = dt.Rows[0]["StakeName"].ToString();
                        lblStakeValue.Text = (('$') + dt.Rows[0]["Invest"].ToString());
                        lblReferal.Text = dt.Rows[0]["RefferId"].ToString();
                        lblPlacement.Text = dt.Rows[0]["PleacementId"].ToString() + "(" + dt.Rows[0]["PlacePosition"].ToString() + ")";
                        lblStakeJoinDate.Text = dt.Rows[0]["JoinDate"].ToString();
                        lblActiveDate.Text = dt.Rows[0]["ActiveDate"].ToString();

                    }
                    else
                    {
                        lvlIsActive.Visible = true;
                        lvlIsActive.Text = "Click the Active button to active your account.";
                        btnActive.Visible = true;
                    }
                }
            }
            catch (Exception)
            {

                //  throw;
            }
        }
 protected void EditBtn_Click(object sender, EventArgs e)
 {
     UserBLL aUser = new UserBLL();
     LinkButton lnkBtn = (LinkButton)sender;
     LumexSessionManager.Add("UserIdForUpdate", lblUserId.Text);
     Response.Redirect("~/setting/User/UserInfoList.aspx");
 }
        protected void allDeletedListButton_Click(object sender, EventArgs e)
        {
            UserBLL user = new UserBLL();

            try
            {
                string fromDate = LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim());
                string toDate = LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim());

                DataTable dt = user.GetDeletedUserListByDateRangeAll(fromDate, toDate, "All");

                deletedListGridView.DataSource = dt;
                deletedListGridView.DataBind();

                if (deletedListGridView.Rows.Count > 0)
                {
                    deletedListGridView.UseAccessibleHeader = true;
                    deletedListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                }
                else
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                user = null;
            }
        }
        protected void blockLinkButton_Click(object sender, EventArgs e)
        {
            LinkButton Btn = (LinkButton)sender;
            GridViewRow row = (GridViewRow)Btn.NamingContainer;
            string UserId = userListGridView.Rows[row.RowIndex].Cells[0].Text.ToString();
            string Status = "";
            try
            {
                if (userListGridView.Rows[row.RowIndex].Cells[6].Text.ToString() == "Yes")
                {
                    Status = "No";
                }
                else
                {
                    Status = "Yes";
                }
                UserBLL userBll = new UserBLL();

                userBll.UpdateUserActivation(UserId, Status);

                string message = " <span class='actionTopic'>" + "Your mail Send Successfully. Please Cheak your Mail Inbox or Spam" + "</span>.";

                MyAlertBox("var callbackOk = function () { window.location = \"/setting/User/ResetUserPassword.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
        }
        protected void btnChangePin_Click(object sender, EventArgs e)
        {
            UserBLL user = new UserBLL();

            try
            {
                if (string.IsNullOrEmpty(currentPinTextBox.Text.Trim()))
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Current Pin field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                }
                else if (string.IsNullOrEmpty(newPinTextBox.Text.Trim()))
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "New Pin field is required.";

                    msgbox.Attributes.Add("Class", "alert alert-warning");
                }
                else if (string.IsNullOrEmpty(confirmNewPinTextBox.Text.Trim()))
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Confirm New Pin field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                }
                else if (newPinTextBox.Text.Trim() != confirmNewPinTextBox.Text.Trim())
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "New Pin & Confirm New Pin do not match.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                }
                else
                {
                    // user.UserId = LumexSessionManager.Get("ActiveLoginId").ToString();

                    /*need to modify this validateUser. */
                    if (user.varifypin((string)LumexSessionManager.Get("ActiveUserId"), currentPinTextBox.Text.Trim()))
                    {

                        user.UpdateUserPin((string)LumexSessionManager.Get("ActiveUserId"),
                            confirmNewPinTextBox.Text.Trim());
                        string message = "Pin <span class='actionTopic'>Updated</span> Successfully.";
                        MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/setting/User/pinset.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                    }
                    else
                    {
                        string message = "<span class='actionTopic'>Invalid</span> Current Pin. You can't change your pin.";
                        MyAlertBox("ErrorAlert(\"" + "Process Failed" + "\", \"" + message + "\");");
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                user = null;
            }
        }
        protected void btnresetPass_click(object sender, EventArgs e)
        {
            UserBLL userBll = new UserBLL();
            Button Btn = (Button)sender;
            GridViewRow row = (GridViewRow)Btn.NamingContainer;
            userBll.UserId = userListGridView.Rows[row.RowIndex].Cells[0].Text.ToString();
            try
            {

                bool status = userBll.CheckUserIdOrMailForResetPass(userBll.UserId);

                //varificationSection.Visible = true;
                //userCheckSection.Visible = false;
                if (status)
                {
                    Random random = new Random();

                    MailContactBLL mailContactBll = new MailContactBLL();
                    userBll.varifycode = random.Next(100000, 999998) + 1;

                    string key = dataEncryptbll.addforvarifycore;
                    string encrypeteduid = dataEncryptbll.EncryptRijndael(userBll.UserId + "#" + userBll.varifycode, key);
                    string url = HttpContext.Current.Request.Url.AbsoluteUri;
                    string[] Partsofurl = url.Split('/');
                    userBll.ActivationUrl = Server.HtmlEncode("http://" + Partsofurl[2] + "/page/varify.aspx/?uid=" + encrypeteduid);

                    bool mailSend = mailContactBll.SendEmailForPasswordReset(userBll);

                    if (mailSend)
                    {
                        string message = " <span class='actionTopic'>" + "Your mail Send Successfully. Please Cheak your Mail Inbox or Spam" + "</span>.";

                        MyAlertBox("var callbackOk = function () { window.location = \"/setting/User/ResetUserPassword.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                    }
                    else
                    {
                        string message = " <span class='actionTopic'>" + "Sorry !! Mail Not Send to this User Please Check User mail or ID is Correct !!!" + "</span>.";
                        MyAlertBox("var callbackOk = function () { window.location = \"/setting/User/ResetUserPassword.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                    }

                }
                else
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Exception";
                    msgDetailLabel.Text = "User Id or Email is Not Correct";
                }

            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
        }
 protected void btnCommissionOK_OnClick(object sender, EventArgs e)
 {
     UserAccountBLL accountBll = new UserAccountBLL();
     UserBLL userBll = new UserBLL();
     accountBll.Amount = txtbxCommissionAmount.Text.Trim();
     userBll.UserId = (string) LumexSessionManager.Get("ActiveUserId");
     if (userBll.varifypin(userBll.UserId,txtbxPinCommission.Text))
     {
         if (Convert.ToDecimal(accountBll.Amount) <= Convert.ToDecimal(lvlCommision.Text))
         {
             bool status =
                 accountBll.UpdateUserIncomeBalanceFromCommission(
                     (string) LumexSessionManager.Get("ActiveUserId"), accountBll.Amount);
             if (status)
             {
                 string message = " <span class='actionTopic'>" + " Income Balance Updated Successfully " +
                                  "</span>.";
                 MyAlertBox(
                     "var callbackOk = function () { window.location = \"/a/account/myaccount.aspx\"; }; SuccessAlert(\"" +
                     "Process Succeed" + "\", \"" + message + "\", callbackOk);");
             }
             else
             {
                 string message = " <span class='actionTopic'>" + " Transfer Failed " +
                                  "</span>.";
                 MyAlertBox(
                     "var callbackOk = function () { window.location = \"/\"; }; SuccessAlert(\"" +
                     "Process Succeed" + "\", \"" + message + "\", \"\");");
             }
         }
         else
         {
             string message = " <span class='actionTopic'>" + "Sorry You don't have sufficent Balance." +
                                  "</span>.";
             MyAlertBox(
                 "var callbackOk = function () { window.location = \"/\"; }; WarningAlert(\"" +
                 "Warning!!" + "\", \"" + message + "\", \"\");");
         }
     }
     else
     {
         string message = " <span class='actionTopic'>" + " Invalid Pin. " +
                                  "</span>.";
         MyAlertBox(
             "var callbackOk = function () { window.location = \"/\"; }; WarningAlert(\"" +
             "Warning!!" + "\", \"" + message + "\", \"\");");
     }
 }
        private void ViewUserInfo()
        {
            UserBLL aUser = new UserBLL();
            try
            {

                if (Session["UserIdForView"] == null)
                {
                    aUser.UserId = LumexSessionManager.Get("ActiveUserId").ToString();
                }
                else
                {
                    aUser.UserId = LumexSessionManager.Get("UserIdForView").ToString();
                }

                lblUserId.Text = aUser.UserId;
                LumexSessionManager.Add("UserIdForUpdate", lblUserId.Text);
                DataTable dt = new DataTable();
                dt = aUser.GetUserInfoByIdForView(aUser.UserId);

                if (dt.Rows.Count > 0)
                {

                    lvlGivenName.Text = dt.Rows[0]["FirstName"].ToString();
                    lvlSureName.Text = dt.Rows[0]["LastName"].ToString();
                    lvlPassPortNo.Text = dt.Rows[0]["PassportNo"].ToString();
                    lvlAddress.Text = dt.Rows[0]["Address"].ToString();
                    lvlCountry.Text = dt.Rows[0]["Country"].ToString();
                    lvlStreet.Text = dt.Rows[0]["House"].ToString();
                    lvlMobileNo.Text = dt.Rows[0]["MobileNo"].ToString();
                    lvlEmail.Text = dt.Rows[0]["Email"].ToString();
                    lvlEmrgConctName.Text = dt.Rows[0]["EmrName"].ToString();
                    lvlEmrgConctAddress.Text = dt.Rows[0]["EmrAdress"].ToString();
                    lvlRelation.Text = dt.Rows[0]["RelationName"].ToString();
                    lvlEmrgConctMobile.Text = dt.Rows[0]["EmrMobile"].ToString();
                    lvlEmrgConctEmail.Text = dt.Rows[0]["EmrEmail"].ToString();
                    lvlEmrgConctCountry.Text = dt.Rows[0]["EmarCountryName"].ToString();

                    LumexSessionManager.Remove("UserIdForView");
                }
            }
            catch (Exception)
            {

                //  throw;
            }
        }
        protected void btnActivation_Click(object sender, EventArgs e)
        {
            try
            {
                UserBLL user = new UserBLL();
                if (user.varifypin((string)LumexSessionManager.Get("ActiveUserId"), txtbxUserPin.Text))
                {
                    UserAccountBLL userAccount = new UserAccountBLL();
                    StakeInfoBLL stakeInfo = new StakeInfoBLL();
                    MailContactBLL mailContactBll = new MailContactBLL();
                    UserBLL userBll = new UserBLL();
                    bool status = userAccount.UpdateUserAccount((string)LumexSessionManager.Get("ActiveUserId"),
                        ddlStakeList.SelectedValue, txtbxStakeKey.Text.Trim());

                    if (status)
                    {
                        if (hdnfldRefActive.Value == "No")
                        {
                            ReceivePaymentWhenActive();
                            genologyBLL genology = new genologyBLL();
                            genology.GenerateBinaryNodeByChileId((string) LumexSessionManager.Get("ActiveUserId"),userAccount.Amount);
                        }
                        string message = " <span class='actionTopic'> Your Account is Activated successfully. Thanks" + "</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { window.location = \"/a/initialdata/initialDataElement.aspx\"; }; SuccessAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", \"\");");
                    }
                    else
                    {

                    }
                    DataTable dt = stakeInfo.GetStakeInfoById(ddlStakeList.SelectedValue);
                    string body = PopulateBody(dt);
                    dt = userBll.GetUserInfoById((string) LumexSessionManager.Get("ActiveUserId"));
                    mailContactBll.SendHtmlFormattedEmail(dt.Rows[0]["Email"].ToString(), "Money Receipt", body);

                }
            }
            catch (Exception)
            {

                //throw;
            }
        }
        public bool sendemailtocompleteResigtration(UserBLL user, string body)
        {
            bool status = false;
            try
            {
                MailMessage mail = new MailMessage();
                LumexDBPlayer db = LumexDBPlayer.Start();
                UserDAL userdal = new UserDAL();
                DataTable dt = userdal.UpdateUserVarificationCode(user, db);
                db.Stop();
                if (dt.Rows.Count > 0)
                {

                    UserMail = user.Email;
                    MailBody = body;

                    //    MailBody = "Dear " + dt.Rows[0][0].ToString() + "\n To complete Your Resigtration Process \r\n\r\n\r\"Please Click the Link :" + user.ActivationUrl + "\r\n\r\n Your Login Name is : " + user.UserId + "\r\n\r\n If any problem feel free to contact site Admin. \r\n";

                }

                //   SmtpClient SmtpServer = new SmtpClient("mail.lovetelsolution.com");
                SmtpClient SmtpServer = new SmtpClient(SystemBLL.MailServer);
                mail.From = new MailAddress(SystemBLL.MailAddess);
                mail.IsBodyHtml = true;
                mail.To.Add(UserMail);
                mail.Subject = "Resigtration Conformation";
                mail.Body = MailBody;
                SmtpServer.Port = SystemBLL.Port;
                SmtpServer.Credentials = new System.Net.NetworkCredential(SystemBLL.MailAddess, SystemBLL.MailPass);
                //SmtpServer.EnableSsl = SystemBLL.Enablessl;
                ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
                SmtpServer.Send(mail);
                status = true;

            }
            catch (Exception)
            {
                throw;
            }
            return status;
        }
        public bool SendEmailForPasswordReset(UserBLL userBll)
        {
            bool status = false;
            try
            {
                LumexDBPlayer db = LumexDBPlayer.Start();
                UserDAL userDAL = new UserDAL();
                userDAL.UpdateUserVarificationCode(userBll, db);
                db.Stop();
                UserMail = userBll.Email;
                MailSubject = "Password Reset Request";
                MailBody = "Dear " + userBll.UserName + "\nTo Reset Your Access password \r\n\r\n\r\"Please Click the Link :" + userBll.ActivationUrl + "\r\n\r\n Your varification code is : " + userBll.varifycode + "\r\n\r\n If any problem feel free to contact site Admin \r\n";

                status = sendemailToConfirm();

            }
            catch (Exception)
            {

                throw;
            }
            return status;
        }
        protected void GetUserById(string userId)
        {
            UserBLL user = new UserBLL();

            try
            {
                DataTable dt = user.GetUserById(userId);

                if (dt.Rows.Count > 0)
                {
                    userIdLabel.Text = dt.Rows[0]["UserId"].ToString();
                    userNameLabel.Text = dt.Rows[0]["UserName"].ToString();
                    //employeeIdLabel.Text = dt.Rows[0]["EmployeeId"].ToString();
                    //departmentLabel.Text = dt.Rows[0]["Department"].ToString();
                    //designationLabel.Text = dt.Rows[0]["Designation"].ToString();
                    //addressLabel.Text = dt.Rows[0]["Address"].ToString();
                    contactNumberLabel.Text = dt.Rows[0]["ContactNumber"].ToString();
                    emailLabel.Text = dt.Rows[0]["Email"].ToString();
                    //nationalIdLabel.Text = dt.Rows[0]["NationalId"].ToString();
                    //passportNumberLabel.Text = dt.Rows[0]["PassportNumber"].ToString();
                    userGroupLabel.Text = dt.Rows[0]["UserGroupName"].ToString();
                }
                else
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                user = null;
            }
        }
        private bool checkDuplicateUser()
        {
            bool isExits = false;
            try
            {
                UserBLL userbll = new UserBLL();
                if (userbll.CheckDuplicateUser(txtbxUserName.Text))
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    msgTitleLabel.Text = "Error!!";
                    msgDetailLabel.Text = "User ID alredy exits!!!";
                    msgbox.Visible = true;
                    isExits = true;

                }

            }
            catch (Exception ex)
            {

                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");

            }
            return isExits;
        }
        private void GetUserByGroupId()
        {
            try
            {
                DataTable dt = new DataTable();
                UserBLL aUserBll = new UserBLL();
                aUserBll.UserGroupId = "UG001";
                dt = aUserBll.GetUserByGroupId(aUserBll);
                if (dt.Rows.Count > 0)
                {
                    GridViewForUser.DataSource = dt;
                    GridViewForUser.DataBind();
                }
                GridViewStyle();
            }
            catch (Exception)
            {

                // throw;
            }
        }
        protected void EditLinkButton_OnClick(object sender, EventArgs e)
        {
            try
            {
                UserBLL aUser = new UserBLL();
                LinkButton lnkBtn = (LinkButton)sender;
                GridViewRow row = (GridViewRow)lnkBtn.NamingContainer;

                Label lblUserId = (Label)GridViewForUser.Rows[row.RowIndex].FindControl("lblUserId");
                LumexSessionManager.Add("UserIdForUpdate", lblUserId.Text);
                Response.Redirect("~/setting/User/UserInfoList.aspx");

            }
            catch (Exception ex)
            {
                msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
        }
        protected void btnUserCreate_click(object sender, EventArgs e)
        {
            try
            {
                if (!checkDuplicateUser())
                {

                    UserBLL aUser = new UserBLL();
                    LoginBll login = new LoginBll();
                    aUser.UserId = txtbxUserName.Text.Trim();
                    aUser.FirstName = txtbxUserName.Text.Trim();
                    aUser.LastName = "";
                    aUser.PassportNo = "";
                    aUser.Address = "";
                    aUser.Country = "";
                    aUser.House = "";
                    aUser.Street = "";
                    aUser.Area = "";
                    aUser.MobileNo = txtbxmobile.Text.Trim();
                    aUser.Email = txtbxemail.Text.Trim();
                    aUser.EmrName = "";
                    aUser.EmrRelation = "";
                    aUser.EmrAddress = "";
                    aUser.EmrMobile = "";
                    aUser.EmeEmail = "";
                    aUser.EmeCountry = "";
                    aUser.ActualPass = "";
                    aUser.UserPin = passwordTextBox.Text;
                    aUser.IsActive = "No";
                    aUser.Isvarified = "Yes";
                    aUser.Createdby = "";
                    aUser.UserGroupId = drpdownGroup.SelectedValue;
                    aUser.Certificate = "";
                    aUser.Password = LumexLibraryManager.EncodeIntoMd5Hash("LTSsL[" + passwordTextBox.Text + "]0");
                    aUser.ActualPass = passwordTextBox.Text;
                    string IsUpload = photoUploadfn(aUser.Email);

                    if (IsUpload == "")
                    {
                        msgbox.Attributes.Add("Class", "alert alert-warning");
                        msgTitleLabel.Text = "Error!!!!";
                        msgDetailLabel.Text = "Pleace Check File Extention or File size.You can only upload Image and size less than 128Kb";
                        msgbox.Visible = true;
                        string message = " <span class='actionTopic'>" + " Pleace Check File Extention or File size.You can only upload Image and size less than 128Kb</span>.";
                        MyAlertBox("var callbackOk = function () { window.location = \"/setting/user/create.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                    }
                    else
                    {

                        aUser.PerPhoto = IsUpload;
                        bool status = aUser.SaveUserInfo();
                        if (status)
                        {

                            //bool st = SendConformationEmail(userbll);
                            //if (st)
                            //{

                            string message = " <span class='actionTopic'>" + "User Create Successfully</span>.";
                            MyAlertBox("var callbackOk = function () { window.location = \"/setting/user/create.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                        }
                        //else
                        //{
                        //    string message = " <span class='actionTopic'>" + "User Create Successfully.But Not Send Please Contact Your Admistration.</span>.";
                        //    MyAlertBox("var callbackOk = function () { window.location = \"/setting/user/list.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                        //}
                        //  }

                        //    }

                        //}

                    }
                }
            }
            catch (Exception ex)
            {

                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");

            }
        }
        protected void txtbxReferId_TextChanged(object sender, EventArgs e)
        {
            try
            {
                usernote.Attributes.Remove("data-content");
                usernote.Attributes.Remove("data-original-title");
                UserBLL userBll = new UserBLL();
                if (txtbxReferId.Text != "")
                {
                    DataTable dt = userBll.GetUserInfoById(txtbxReferId.Text);
                    if (dt.Rows.Count > 0)
                    {
                        string TransferToName = "Name:" + dt.Rows[0]["FirstName"].ToString() + " " + dt.Rows[0]["LastName"].ToString();
                        string Contactinfo = "Cell:" + dt.Rows[0]["MobileNo"].ToString() + ", Email:" +
                                             dt.Rows[0]["Email"].ToString();
                        usernote.Attributes.Add("data-content", Contactinfo);
                        usernote.Attributes.Add("data-original-title", TransferToName);
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
        protected void txtbxPlacementId_TextChanged(object sender, EventArgs e)
        {
            try
            {

                Areffer.Attributes.Remove("data-content");
                Areffer.Attributes.Remove("data-original-title");
                UserBLL userBll = new UserBLL();
                if (txtbxPlacementId.Text != "")
                {
                    if (txtbxPlacementId.Text != txtbxUserName.Text)
                    {
                        DataTable dt = userBll.GetUserInfoById(txtbxPlacementId.Text);
                        if (dt.Rows.Count > 0)
                        {
                            if (userBll.checkPlacementIdValidity(dt.Rows[0]["UserId"].ToString(),
                                ddlPosition.SelectedValue))
                            {
                                txtbxPlacementId.Text = "";
                                string message = " <span class='actionTopic'>" +
                                                 " Placement Informarion is not correct!!" +
                                                 ddlPosition.SelectedItem.Text +
                                                 " Is not free of the Placement Id</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { window.location = \"/page/registration.aspx\"; }; WarningAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", \"\");");
                                hdnvalidplace.Value = "1";
                            }
                            else
                            {
                                string TransferToName = "Name:" + dt.Rows[0]["FirstName"].ToString() + " " +
                                                        dt.Rows[0]["LastName"].ToString();
                                string Contactinfo = "Cell:" + dt.Rows[0]["MobileNo"].ToString() + ", Email:" +
                                                     dt.Rows[0]["Email"].ToString();
                                Areffer.Attributes.Add("data-content", Contactinfo);
                                Areffer.Attributes.Add("data-original-title", TransferToName);
                                hdnvalidplace.Value = "0";

                            }
                        }
                    }
                    else
                    {
                        txtbxPlacementId.Text = "";
                        ddlPosition.SelectedIndex = 0;
                        string message = " <span class='actionTopic'>" +
                                         " Placement Informarion is not correct!!" +
                                         ddlPosition.SelectedItem.Text +
                                         " Is not free of the Placement Id</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { window.location = \"/page/registration.aspx\"; }; WarningAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", \"\");");
                        hdnvalidplace.Value = "1";
                    }
                }
            }
            catch (Exception)
            {

                //  throw;
            }
        }
        protected void txtbxUserName_TextChanged(object sender, EventArgs e)
        {
            try
            {
                iconuserName.Attributes.Remove("class");
                lblUsernameNote.Visible = false;
                UserBLL user = new UserBLL();
                Regex reg = new Regex(@"^[a-z0-9_-]{5,15}$");

                if (reg.IsMatch(txtbxUserName.Text))
                {
                    if (user.CheckDuplicateUser(txtbxUserName.Text.Trim()))
                    {
                        //  iconuserName.Attributes.Remove("class");
                        iconuserName.Attributes.Add("class", "icon icon-ban-circle text-error");
                        hdnfldduplicate.Value = "1";
                        txtbxUserName.Focus();
                    }
                    else
                    {
                        // iconuserName.Attributes.Remove("class");
                        iconuserName.Attributes.Add("class", "icon icon-ok-sign text-success");
                        hdnfldduplicate.Value = "0";
                        txtbxFirstName.Focus();
                    }
                }
                else
                {
                    lblUsernameNote.Visible = true;
                    lblUsernameNote.Text = "User Name must be 5-15 char small letter alpha char (_ allow) ei. jhonsmith_ or jhonsmith ";

                }
            }
            catch (Exception)
            {

                //throw;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                UserBLL aUser = new UserBLL();
                if (txtbxUserName.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "User Name field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxUserName.Focus();
                }
                else if (txtbxFirstName.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "First Name field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxFirstName.Focus();
                }
                else if (txtbxLastName.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Last Name field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxLastName.Focus();
                }
                else if (txtbxAddress.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Address field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxAddress.Focus();
                }
                else if (txtbxHouse.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "House No field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxHouse.Focus();
                }
                else if (txtbxStreet.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Street field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxStreet.Focus();
                }
                else if (txtbxCell.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Cell Number field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxCell.Focus();
                }
                else if (txtbxCellConfrm.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Cell Confirm field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxCellConfrm.Focus();
                }
                else if (txtbxEmail.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Email field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxEmail.Focus();
                }
                else if (txtbxPin.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Pin field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxPin.Focus();
                }
                else if (txtbxReferId.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Reffer ID field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxReferId.Focus();
                }
                else if (txtbxPlacementId.Text == ""||txtbxPlacementId.Text==txtbxUserName.Text)
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Placement ID field is required. or Not valid.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    txtbxPlacementId.Text = "";
                    txtbxPlacementId.Focus();
                }
                else if (ddlPosition.SelectedItem.Text == "")
                {
                    msgbox.Visible = true;
                    msgTitleLabel.Text = "Validation!!!";
                    msgDetailLabel.Text = "Join Position field is required.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");
                    ddlPosition.Focus();
                }

                else
                {
                    if (!aUser.CheckDuplicateUser(txtbxUserName.Text) && hdnvalidplace.Value == "0")
                    {

                        LoginBll login = new LoginBll();
                        aUser.UserId = txtbxUserName.Text.Trim();
                        aUser.FirstName = txtbxFirstName.Text.Trim();
                        aUser.LastName = txtbxLastName.Text.Trim();
                        aUser.PassportNo = txtbxPassportNo.Text.Trim();
                        aUser.Address = txtbxAddress.Text.Trim();
                        aUser.Country = ddlCountry.SelectedValue;
                        aUser.House = txtbxHouse.Text.Trim();
                        aUser.Street = txtbxStreet.Text.Trim();
                        aUser.Area = txtbxArea.Text.Trim();
                        aUser.MobileNo = txtbxCell.Text.Trim();
                        aUser.Email = txtbxEmail.Text.Trim();
                        aUser.EmrName = txtcontactPerson.Text.Trim();
                        aUser.EmrRelation = ddlContactRelation.SelectedValue;
                        aUser.EmrAddress = txtbxContactAddress.Text.Trim();
                        aUser.EmrMobile = txtbxContactMobile.Text.Trim();
                        aUser.EmeEmail = txtContactEmail.Text.Trim();
                        aUser.EmeCountry = ddlContactCountry.SelectedValue;
                        aUser.UserGroupId = "UG003";
                        aUser.Password =
                            (string)
                                LumexLibraryManager.EncodeIntoMd5Hash("LTSsL[" + txtpxPasswordset.Text.Trim() + "]0");
                        ;
                        aUser.ActualPass = retypePassword.Text.Trim();
                        aUser.UserPin = txtbxPin.Text.Trim();
                        aUser.IsActive = "No";
                        aUser.PerPhoto = "";
                        aUser.Isvarified = "No";
                        aUser.Createdby = "";
                        bool status = aUser.SaveUserInfo();
                        if (status)
                        {

                            if (txtbxPlacementId.Text != "" && ddlPosition.SelectedValue != "" &&
                                txtbxReferId.Text != "")
                            {
                                aUser.InsertIntoGenolgyTree(txtbxPlacementId.Text, ddlPosition.SelectedValue,
                                    txtbxReferId.Text, aUser.UserId);
                            }
                            Random random = new Random();
                            MailContactBLL mailContactBll = new MailContactBLL();
                            aUser.varifycode = random.Next(100000, 999998) + 1;

                            string key = dataEncryptbll.addforvarifycore;
                            string encrypeteduid = dataEncryptbll.EncryptRijndael(
                                aUser.UserId + "#" + aUser.varifycode, key);
                            string url = HttpContext.Current.Request.Url.AbsoluteUri;
                            string[] Partsofurl = url.Split('/');
                            aUser.ActivationUrl =
                                Server.HtmlEncode("http://" + Partsofurl[2] + "/page/varify.aspx/?uid=" + encrypeteduid);
                            string body = PopulateBody(aUser);

                            bool mailSend = mailContactBll.sendemailtocompleteResigtration(aUser, body);
                            aUser = null;
                            ClearTextBox();

                        }
                    }
                    else
                    {
                        string message = " <span class='actionTopic'>" + " Placement Informarion is not correct!!" +
                                         ddlPosition.SelectedItem.Text + " Is not free of the Placement Id</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { window.location = \"/page/registration.aspx\"; }; WarningAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", \"\");");
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
        private void checkuserPinchangevalidity()
        {
            try
            {
                UserBLL user = new UserBLL();

                DataTable dt = user.checkuserPinchangevalidity((string)LumexSessionManager.Get("ActiveUserId"));

                lblChangeCout.Text = dt.Rows[0]["ModifyCount"].ToString();
                if (Convert.ToInt32(lblChangeCout.Text) >= 3)
                {
                    if (dt.Rows[0]["IsPaid"].ToString() == "Yes")
                    {
                        currentPinTextBox.Enabled = true;
                        btnPayforPinGenerate.Visible = false;

                    }
                    else
                    {
                        currentPinTextBox.Enabled = false;
                        btnPayforPinGenerate.Visible = true;

                    }

                }
                // Check change conditaion now.
            }
            catch (Exception)
            {

                //throw;
            }
        }
 protected void GetUserInfoList()
 {
     try
     {
         DataTable dt = new DataTable();
         UserBLL aUserBll = new UserBLL();
         dt = aUserBll.GetUserInfoList();
         if (dt.Rows.Count > 0)
         {
             userListGridView.DataSource = dt;
             userListGridView.DataBind();
         }
         GridViewStyle();
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
         MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
     }
 }
        protected void GetUserList()
        {
            UserBLL user = new UserBLL();

            try
            {
                DataTable dt = user.GetActiveUserList();
                userListGridView.DataSource = dt;
                userListGridView.DataBind();

                if (dt.Rows.Count < 1)
                {
                    msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
                GridviewHeadStyle();
            }
            catch (Exception ex)
            {
                msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                user = null;
            }
        }
 private string PopulateBody(UserBLL userBll)
 {
     string body = string.Empty;
     using (StreamReader reader = new StreamReader(Server.MapPath("~/assets/oth/thanksemail.html")))
     {
         body = reader.ReadToEnd();
     }
     body = body.Replace("{UserId}", userBll.UserId);
     body = body.Replace("{Password}", userBll.ActualPass);
     body = body.Replace("{Cell}", userBll.MobileNo);
     body = body.Replace("{PIN}", userBll.UserPin);
     body = body.Replace("{varifyurl}", userBll.ActivationUrl);
     return body;
 }
        private void getUserPasswordresetvalidity(string UserId)
        {
            try
            {
                string[] id = UserId.Split('#');
                UserBLL usrbll = new UserBLL();
                hdnfldUserID.Value = usrbll.UserId = id[0];
                DataTable dt = usrbll.getUserPasswordsetValidity();
                if (dt.Rows.Count > 0)
                {

                    userNameLabel.Text = dt.Rows[0][0].ToString();
                    if (dt.Rows[0]["IsBlocked"].ToString() == "No")
                    {
                        if (dt.Rows[0]["Isvarify"].ToString() == "Yes" && dt.Rows[0]["FirstTime"].ToString() != "0")
                        {

                            string message = " <span class='actionTopic'>" +
                                             "Your Email id Succesfully Varified. You may LOG IN in now. Click ok to log in." +
                                             "</span>.";
                            MyAlertBox(
                                "var callbackOk = function () { window.location = \"/login.aspx\"; }; SuccessAlert(\"" +
                                "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                        }
                        else if (dt.Rows[0]["Isvarify"].ToString() == "Yes" && !string.IsNullOrEmpty(dt.Rows[0]["VarificationCode"].ToString()) && dt.Rows[0]["FirstTime"].ToString() != "1")
                        {
                            varificationSection.Visible = true;
                            string message = " <span class='actionTopic'>" +
                                             "Please Insert your varification code and Change Your Password!!" +
                                             "</span>.";
                            MyAlertBox("var callbackOk = function () { window.location = \"\"; }; SuccessAlert(\"" +
                                       "Process Succeed" + "\", \"" + message + "\", \"\");");

                            hdnfldVarifiCode.Value =
                                dataEncryptbll.EncryptRijndael(dt.Rows[0]["VarificationCode"].ToString(),
                                    dataEncryptbll.addforvarifycore);

                        }
                        else
                        {
                            string message = " <span class='actionTopic'>" +
                                             "Your Request Time out or this link already used. Please Try again leter or Contact with System Admin" +
                                             "</span>.";
                            MyAlertBox(
                                "var callbackOk = function () { window.location = \"/login.aspx\"; }; WarningAlert(\"" +
                                "Warning!!" + "\", \"" + message + "\", callbackOk);");

                            // MyAlertBox("var callbackOk = function () { window.location = \"/login\"; }; ErrorAlert(\"" + "Warning" + "\", \"" + message + "\", callbackOk);");

                        }
                    }
                    else
                    {
                        string message = " <span class='actionTopic'>" +
                                             "This account is blocked. Please Try again leter or Contact with System Admin" +
                                             "</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { window.location = \"/login.aspx\"; }; WarningAlert(\"" +
                            "Warning!!" + "\", \"" + message + "\", callbackOk);");
                    }

                }
                else
                {
                    string message = " <span class='actionTopic'>" + "Your Request Time out Please Try again leter or Contact with System Admin" + "</span>.";
                    MyAlertBox("var callbackOk = function () { window.location = \"/login.aspx\"; }; WarningAlert(\"" + "Warning!!" + "\", \"" + message + "\", callbackOk);");
                    //   MyAlertBox("var callbackOk = function () { window.location = \"/login\"; }; ErrorAlert(\"" + "Warning" + "\", \"" + message + "\", callbackOk);");

                }

            }
            catch (Exception ex)
            {

                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
        }