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 GenerateButton_Click(object sender, EventArgs e)
        {
            try
            {

                UserAccountBLL userAccount=new UserAccountBLL();
                userAccount.TransferAmount = Convert.ToDecimal(txtbxAmount.Text.Trim());
                bool status = userAccount.ReceivePaymentMoney(txtbxAmount.Text.Trim());
                if (status)
                {
                    string message = "Payment <span class='actionTopic'>Received</span> Successfully.";
                    MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/moneygerate.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 + "\", \"\");");
            }
            finally
            {
              //  MyAlertBox("MyOverlayStop();");
            }
        }
        protected void dailyBonusGenerateButton_Click(object sender, EventArgs e)
        {
            try
            {
                UserAccountBLL accountBll = new UserAccountBLL();

                bool status = accountBll.generateDailyBonus(DateTime.Now.ToString("dd/MM/yyyy"));
                if (status)
                {
                    accountBll.InsertReceivePaymentWhenDailybonus();
                }

                DataTable dt = accountBll.getDailybounsListbyDateRange(DateTime.Now.ToString("dd/MM/yyyy"),
                    DateTime.Now.ToString("dd/MM/yyyy"));
                GridDailyBonusGenerate.DataSource = dt;
                GridDailyBonusGenerate.DataBind();
                if (GridDailyBonusGenerate.Rows.Count > 0)
                {
                    // btnTodayBonusGenerate.Visible = true;
                    GridDailyBonusGenerate.UseAccessibleHeader = true;
                    GridDailyBonusGenerate.HeaderRow.TableSection = TableRowSection.TableHeader;
                }

            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                MyAlertBox("MyOverlayStop();");
            }
        }
 protected void btnDepositOk_OnClick(object sender, EventArgs e)
 {
     UserAccountBLL accountBll = new UserAccountBLL();
     UserBLL userBll = new UserBLL();
     bool status = false;
     accountBll.Amount = txtbxDepositAmmount.Text.Trim();
     userBll.UserId = (string)LumexSessionManager.Get("ActiveUserId");
     if (userBll.varifypin(userBll.UserId, txtbxDepositPin.Text))
     {
         if (Convert.ToDecimal(accountBll.Amount) <= Convert.ToDecimal(lvlDeposit.Text))
         {
             status =
                 accountBll.UpdateUserIncomeBalanceFromDeposit((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 = \"/\"; }; WarningAlert(\"" +
                     "Warning!!" + "\", \"" + 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'>" + " Pin is Incorrect " +
                                  "</span>.";
         MyAlertBox(
             "var callbackOk = function () { window.location = \"/\"; }; WarningAlert(\"" +
             "Warning!!" + "\", \"" + message + "\", \"\");");
     }
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                UserAccountBLL account = new UserAccountBLL();
                account.Type = ddlType.SelectedValue;
                account.TypeName = ddlType.SelectedItem.Text.ToString().Trim();
                account.UserId = (string)LumexSessionManager.Get("ActiveUserId");
                account.BankName = txtbxBankName.Text.Trim();
                account.BankAccountNo = txtbxAccountNo.Text.Trim();
                account.SwiftCode = txtbxSwiftCode.Text.Trim();
                account.CardOwnerName = txtbxCardOwnerName.Text.Trim();
                account.CardNumber = txtbxCardNumber.Text.Trim();
                account.CardExpireDate = txtbxCardExpireDate.Text.Trim();
                account.GateWayOwnerName = txtbxOwnerName.Text.Trim();
                account.OnlineEmail = txtbxEmail.Text.Trim();
                string message = "";
                if (btnSubmit.Text == "Submit")
                {

                    bool status = account.SavePaymentInfo();
                    if (status)
                    {
                        message = "Your " + ddlType.SelectedItem.Text + " payment Information has been saved.";
                        MyAlertBox(
                            "var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/paymentmethod.aspx\"; }; WarningAlert(\"" +
                            "Warning!!" + "\", \"" + message + "\", \"\");");
                    }

                }
                else
                {
                    //string serial = LumexSessionManager.Get("SerialForUpdate").ToString();
                    bool status = account.UpdatePaymentInfoBySerial();
                    if (status)
                    {
                        message = "Your " + ddlType.SelectedItem.Text + " payment Information has been Updated.";
                        MyAlertBox(
                            "var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/paymentmethod.aspx\"; }; WarningAlert(\"" +
                            "Warning!!" + "\", \"" + message + "\", \"\");");
                    }
                }
            }

            catch (Exception)
            {
                //throw;
            }
        }
        protected void RejectKeyLinkButton_Click(object sender, EventArgs e)
        {
            LinkButton lnkBtn = (LinkButton)sender;
            GridViewRow row = (GridViewRow)lnkBtn.NamingContainer;

            string Id = GridViewWithdrawRequest.Rows[row.RowIndex].Cells[0].Text.ToString();

            UserAccountBLL userAccount = new UserAccountBLL();

            userAccount.updateWithdrawRequest(Id, "R");
            string message = " <span class='actionTopic'>" +
                                         "Transfer Reject successfully." + "</span>.";
            MyAlertBox(
                "var callbackOk = function () { window.location = \"/a/stake/stakekeymanage.aspx\"; }; WarningAlert(\"" +
                "Process Failed" + "\", \"" + message + "\", \"\");");
            ViewButton_Click(sender, e);
        }
        protected void btnPayforPinGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                UserAccountBLL AccountBll = new UserAccountBLL();

                if (AccountBll.checkUserIncomeAmounttoActin(5, (string)LumexSessionManager.Get("ActiveUserId")))
                {
                    AccountBll.InsertReceivePaymentWhenPinChange();
                }

            }
            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;
            }
        }
        protected void btnPurchaseKey_Click(object sender, EventArgs e)
        {
            try
            {
                divStakePurchase.Visible = true;

                UserAccountBLL accountBll = new UserAccountBLL();
                DataTable dt = accountBll.getAccountSummaryById((string)LumexSessionManager.Get("ActiveUserId"));

                lblIncome.Text = dt.Rows[0]["Income"].ToString();
                lblFxFund.Text = dt.Rows[0]["FxFund"].ToString();

            }
            catch (Exception)
            {

                //throw;
            }
        }
        private void getgeneratedMoneyList()
        {
            try
            {
                UserAccountBLL userAccount = new UserAccountBLL();
               DataTable dt =  userAccount.getGeneratedMoneyList();
               GridViewGeneratedMoneyList.DataSource = dt;
               GridViewGeneratedMoneyList.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)
            {

                //throw;
            }
        }
        protected void ViewButton_Click(object sender, EventArgs e)
        {
            try
            {
                UserAccountBLL userAccount = new UserAccountBLL();
                DataTable dt = userAccount.getUserIncomeStatementById(txtbxUserId.Text, LumexLibraryManager.ParseAppDate(fromDateTextBox.Text), LumexLibraryManager.ParseAppDate(toDateTextBox.Text));

                DesignGridviewBalaceSheet(dt);

            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                //MyAlertBox("MyOverlayStop();");
            }
        }
        protected void ViewButton_Click(object sender, EventArgs e)
        {
            try
            {

                UserAccountBLL accountBll = new UserAccountBLL();
                DataTable dt = new DataTable();
                if ((string)LumexSessionManager.Get("UserGroupId") == "UG003")
                {
                    dt = accountBll.getMatchingCommissionListbyDateRangeByUserId(fromDateTextBox.Text, toDateTextBox.Text, (string)LumexSessionManager.Get("ActiveUserId"));
                }
                else
                {
                    dt = accountBll.getMatchingCommissionListbyDateRange(fromDateTextBox.Text, toDateTextBox.Text);

                }
                GridMatchCommissionGenerate.DataSource = dt;
                GridMatchCommissionGenerate.DataBind();
                if (GridMatchCommissionGenerate.Rows.Count > 0)
                {
                    // btnTodayBonusGenerate.Visible = true;
                    GridMatchCommissionGenerate.UseAccessibleHeader = true;
                    GridMatchCommissionGenerate.HeaderRow.TableSection = TableRowSection.TableHeader;
                }

            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                //  MyAlertBox("MyOverlayStop();");
            }
        }
        protected void dailyBonusGenerateButton_Click(object sender, EventArgs e)
        {
            try
            {
                UserAccountBLL accountBll = new UserAccountBLL();
                genologyBLL genology = new genologyBLL();

                bool status = genology.generateBainaryMatchData();
                DataTable dt = genology.getNodeList();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    decimal LeftAmount = 0;
                    decimal RightAmount = 0;

                    genology.getNodeLeftRightAmount(dt.Rows[i]["NodeID"].ToString(), out LeftAmount, out RightAmount);
                    if (LeftAmount > 0 || RightAmount > 0)
                    {
                        genology.CalculateMatchingCommission(dt.Rows[i]["NodeID"].ToString(), LeftAmount, RightAmount);
                    }
                }
                string message = "Matching Commission  <span class='actionTopic'>Calculate</span> Successfully Done. Thanks.";
                MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/withdraw.aspx\"; }; SuccessAlert(\"" +
                    "Process Succeed" + "\", \"" + message + "\", \"\");");

            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                MyAlertBox("MyOverlayStop();");
            }
        }
        private void getPaymentMethodList(string UserId)
        {
            UserAccountBLL account = new UserAccountBLL();
            DataTable dt = account.GetPaymentInfoNyId(UserId, ddlType.SelectedValue);
            if (ddlType.SelectedValue == "0")
            {
                //GridViewPaymentMethod.Columns["UserId"].Visible = true;
                GridViewPaymentMethod.Columns[1].Visible = true;
                GridViewPaymentMethod.Columns[2].Visible = true;
                GridViewPaymentMethod.Columns[3].Visible = true;
                GridViewPaymentMethod.Columns[4].Visible = true;
                GridViewPaymentMethod.Columns[5].Visible = true;
                //
                GridViewPaymentMethod.Columns[6].Visible = false;
                GridViewPaymentMethod.Columns[7].Visible = false;
                GridViewPaymentMethod.Columns[8].Visible = false;
                GridViewPaymentMethod.Columns[9].Visible = false;
                GridViewPaymentMethod.Columns[10].Visible = false;

                GridViewPaymentMethod.DataSource = dt;
                GridViewPaymentMethod.DataBind();
                GridviewHeadStyle();
            }
            else if (ddlType.SelectedValue == "1")
            {
                GridViewPaymentMethod.Columns[1].Visible = true;
                GridViewPaymentMethod.Columns[6].Visible = true;
                GridViewPaymentMethod.Columns[7].Visible = true;
                GridViewPaymentMethod.Columns[8].Visible = true;
                //For Others
                GridViewPaymentMethod.Columns[2].Visible = false;
                GridViewPaymentMethod.Columns[3].Visible = false;
                GridViewPaymentMethod.Columns[4].Visible = false;
                GridViewPaymentMethod.Columns[5].Visible = false;
                GridViewPaymentMethod.Columns[9].Visible = false;
                GridViewPaymentMethod.Columns[10].Visible = false;
                GridViewPaymentMethod.DataSource = dt;
                GridViewPaymentMethod.DataBind();
                GridviewHeadStyle();
            }
            else if (ddlType.SelectedValue == "2")
            {
                GridViewPaymentMethod.Columns[1].Visible = true;
                GridViewPaymentMethod.Columns[9].Visible = true;
                GridViewPaymentMethod.Columns[10].Visible = true;
                //
                GridViewPaymentMethod.Columns[2].Visible = false;
                GridViewPaymentMethod.Columns[3].Visible = false;
                GridViewPaymentMethod.Columns[4].Visible = false;
                GridViewPaymentMethod.Columns[5].Visible = false;
                GridViewPaymentMethod.Columns[6].Visible = false;
                GridViewPaymentMethod.Columns[7].Visible = false;
                GridViewPaymentMethod.Columns[8].Visible = false;
                GridViewPaymentMethod.DataSource = dt;
                GridViewPaymentMethod.DataBind();
                GridviewHeadStyle();
            }
        }
        private void LoadPaymentMethodList()
        {
            try
            {
                UserAccountBLL account = new UserAccountBLL();
                string Type = "";
                if (ddlType.SelectedValue == "0")
                {
                    Type = "0";
                }
                else if (ddlType.SelectedValue == "2")
                {
                    Type = "1";
                }
                else if (ddlType.SelectedValue == "3")
                {
                    Type = "2";
                }

                DataTable dt = account.GetPaymentInfoNyIdandType((string)LumexSessionManager.Get("ActiveUserId"),Type);

                if (ddlType.SelectedValue == "0")
                {
                    ddlPaymentMethod.Items.Clear();
                    ddlPaymentMethod.DataSource = dt;
                    ddlPaymentMethod.DataTextField = "BankName";
                    ddlPaymentMethod.DataValueField = "Account";
                    ddlPaymentMethod.DataBind();
                    ddlPaymentMethod.Items.Insert(0, "Select Here..");
                    ddlPaymentMethod.SelectedIndex = 0;
                    ddlPaymentMethod.Items[0].Value = "";

                }
                else if (ddlType.SelectedValue == "2")
                {
                    ddlPaymentMethod.Items.Clear();
                    ddlPaymentMethod.DataSource = dt;
                    ddlPaymentMethod.DataTextField = "CardNo";
                    ddlPaymentMethod.DataValueField = "CardWoner";
                    ddlPaymentMethod.DataBind();
                    ddlPaymentMethod.Items.Insert(0, "Select Here..");
                    ddlPaymentMethod.SelectedIndex = 0;
                    ddlPaymentMethod.Items[0].Value = "";
                }
                else if (ddlType.SelectedValue == "3")
                {
                    ddlPaymentMethod.Items.Clear();
                    ddlPaymentMethod.DataSource = dt;
                    ddlPaymentMethod.DataTextField = "GatewayOwner";
                    ddlPaymentMethod.DataValueField = "GatewayEmail";
                    ddlPaymentMethod.DataBind();
                    ddlPaymentMethod.Items.Insert(0, "Select Here..");
                    ddlPaymentMethod.SelectedIndex = 0;
                    ddlPaymentMethod.Items[0].Value = "";
                }
            }
            catch (Exception)
            {

               // throw;
            }
        }
        protected void EditLinkButton_OnClick(object sender, EventArgs e)
        {
            try
            {
                UserAccountBLL user = new UserAccountBLL();
                LinkButton lnkBtn = (LinkButton)sender;
                GridViewRow row = (GridViewRow)lnkBtn.NamingContainer;
                string serial = GridViewPaymentMethod.Rows[row.RowIndex].Cells[0].Text.ToString();
                LumexSessionManager.Add("SerialForUpdate", lblSerial.Text);
                DataTable dt = user.GetPaymentMethodInfoBySerial(serial);
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["GatewayType"].ToString() == "0")
                    {
                        divCard.Visible = false;
                        divCardExpireDate.Visible = false;
                        divCardOwner.Visible = false;
                        divOnlineEmail.Visible = false;
                        divOwnerName.Visible = false;
                        divBankName.Visible = true;
                        divBank.Visible = true;
                        divSwift.Visible = true;
                        txtbxBankName.Text = dt.Rows[0]["BankName"].ToString();
                        txtbxAccountNo.Text = dt.Rows[0]["BankAccount"].ToString();
                        txtbxSwiftCode.Text = dt.Rows[0]["SwiftCode"].ToString();
                        btnSubmit.Text = "Update";
                        ddlType.SelectedValue = "0";
                    }
                    else if (dt.Rows[0]["GatewayType"].ToString() == "1")
                    {
                        divCard.Visible = true;
                        divCardExpireDate.Visible = true;
                        divCardOwner.Visible = true;
                        divOnlineEmail.Visible = false;
                        divOwnerName.Visible = false;
                        divBankName.Visible = false;
                        divBank.Visible = false;
                        divSwift.Visible = false;
                        txtbxCardOwnerName.Text = dt.Rows[0]["CardWoner"].ToString();
                        txtbxCardNumber.Text = dt.Rows[0]["CardNo"].ToString();
                        txtbxCardExpireDate.Text = dt.Rows[0]["ExpireDate"].ToString();
                        btnSubmit.Text = "Update";
                        ddlType.SelectedValue = "1";
                    }
                    else if (dt.Rows[0]["GatewayType"].ToString() == "2")
                    {
                        divCard.Visible = false;
                        divCardExpireDate.Visible = false;
                        divCardOwner.Visible = false;
                        divOnlineEmail.Visible = true;
                        divOwnerName.Visible = true;
                        divBankName.Visible = false;
                        divBank.Visible = false;
                        divSwift.Visible = false;
                        txtbxEmail.Text = dt.Rows[0]["GatewayEmail"].ToString();
                        txtbxOwnerName.Text = dt.Rows[0]["GatewayOwner"].ToString();
                        btnSubmit.Text = "Update";
                        ddlType.SelectedValue = "2";

                    }
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
Example #17
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                LoginBll loginbll = new LoginBll();
                loginbll.UserId = (string)LumexSessionManager.Get("ActiveUserId");
                loginbll.UserPass = txtbxPassword.Text.Trim();
                if (loginbll.VerifyPassword())
                {

                    StakeInfoBLL stake = new StakeInfoBLL();
                    int TotalPin = Convert.ToInt16(txtbxTotalPin.Text);
                    DataTable dt = new DataTable();
                    DataRow dr = null;
                    dt.Columns.Add(new DataColumn("StakeId"));
                    dt.Columns.Add(new DataColumn("StakePin"));
                    dt.Columns.Add(new DataColumn("IsActive"));
                    for (int i = 0; i < TotalPin; )
                    {
                        Random random = new Random();

                        string pinserial = GetSerialNumber();

                        dr = dt.NewRow();
                        if (!stake.CheckDuplicateKey(pinserial))
                        {
                            dr["StakeId"] = ddlStakeList.SelectedValue;
                            dr["StakePin"] = pinserial;
                            dr["IsActive"] = "Yes";
                            dt.Rows.Add(dr);
                            i++;
                        }
                    }
                    if (dt.Rows.Count == TotalPin && TotalPin > 0)
                    {

                        bool status = stake.SaveGeneratedPin(dt);
                        if (status)
                        {
                            UserAccountBLL accountBll = new UserAccountBLL();
                            accountBll.TotalAmount = Convert.ToDecimal(txtbxTotalPin.Text)*
                                                  stake.getstakeAmountByStakeId(ddlStakeList.SelectedValue);
                            accountBll.Particular = "Generate PIN Amount-" + accountBll.TotalAmount.ToString() + " of Stake" +
                                                ddlStakeList.SelectedItem.Text;
                            accountBll.RPType = "CR";
                            accountBll.AffectforId = "";
                            accountBll.Affectfor = "PIN Generate";

                            accountBll.InsertReceivePaymentWhenAffectIncome();

                            GetGeneratedPinList();
                            string message = " <span class='actionTopic'> The" + TotalPin.ToString() +
                                             " is Generated successfully. Thanks" + "</span>.";
                            MyAlertBox(
                                "var callbackOk = function () { window.location = \"/a/initialdata/initialDataElement.aspx\"; }; SuccessAlert(\"" +
                                "Process Succeed" + "\", \"" + message + "\", \"\");");
                        }
                    }
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Password Miss Match!!"; msgDetailLabel.Text = "Sorry your given password don't Match. Try Correct one.";
                    msgbox.Attributes.Add("Class", "alert alert-warning");

                }

            }
            catch (Exception)
            {

                throw;
            }
        }
        private void getmyAccountSummary(string UserId)
        {
            try
            {
                UserAccountBLL userAccount = new UserAccountBLL();
                DataTable dt = new DataTable();
                dt = userAccount.getMoneyGenerateAmountById(UserId);
                if (dt.Rows.Count > 0)
                {
                    lvlMoneyGenerate.Text = (('$') + dt.Rows[0][0].ToString());
                }
                dt = userAccount.getCommissionById(UserId);
                if (dt.Rows.Count > 0)
                {
                    lvlCommission.Text = (('$') + dt.Rows[0][0].ToString());
                }
                dt = userAccount.getDailyBonusById(UserId);
                if (dt.Rows.Count > 0)
                {
                    lvlDailyBonus.Text = (('$') + dt.Rows[0][0].ToString());
                }

            }
            catch (Exception)
            {

                // throw;
            }
        }
        private void getmyAccountSummary(string UserId)
        {
            try
            {
                UserAccountBLL userAccount = new UserAccountBLL();
                DataTable dt = userAccount.getAccountSummaryById(UserId);
                if (dt.Rows.Count > 0)
                {
                    lvlIncomeWallet.Text = (('$') + dt.Rows[0]["Income"].ToString());
                    lvlDepositWallet.Text = (('$') +dt.Rows[0]["Deposit"].ToString());
                    lvlCommisionWallet.Text = (('$') + dt.Rows[0]["Commission"].ToString());
                    lvlFxFund.Text = (('$') + dt.Rows[0]["FxFund"].ToString());
                }
                else
                {

                    lvlIncomeWallet.Text = "0";
                    lvlDepositWallet.Text = "0";
                    lvlCommisionWallet.Text = "0";
                    lvlFxFund.Text = "0";
                }
            }
            catch (Exception)
            {

                // throw;
            }
        }
        protected void ViewButton_Click(object sender, EventArgs e)
        {
            //Test To confirm

            UserAccountBLL userAccount = new UserAccountBLL();
            userAccount.historyOf = Convert.ToInt32(ddlHistory.SelectedValue);

            if (userAccount.historyOf == 0)
            {
                try
                {
                    DataTable dt = userAccount.getMoneyGenerateAmountByDateRangeById(fromDateTextBox.Text, toDateTextBox.Text, (string)LumexSessionManager.Get("ActiveUserId"));
                    GridViewGeneratedMoneyList.DataSource = dt;
                    GridViewGeneratedMoneyList.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)
                {

                    //throw;
                }
            }
            else if (userAccount.historyOf == 1)
            {

                try
                {
                    var j = 0;
                    DataTable dt = userAccount.getDailybounsListbyDateRange(fromDateTextBox.Text, toDateTextBox.Text);
                    DataTable newTable = new DataTable();
                    DataColumn column;
                    column = newTable.Columns.Add();
                    column.ColumnName = "BonusDate";
                    column.DataType = typeof(DateTime);

                    column = newTable.Columns.Add();
                    column.ColumnName = "DailyBonus";
                    column.DataType = typeof(string);
                    DateTime StartDate = DateTime.ParseExact(fromDateTextBox.Text, "dd/MM/yyyy", null); ; ;
                    DateTime EndDate =  DateTime.ParseExact(toDateTextBox.Text,"dd/MM/yyyy",null);;

                    for (var i = StartDate; i <= EndDate; i = i.AddDays(1))
                    {

                        double amount = 0;
                        while (j < dt.Rows.Count && i ==  DateTime.ParseExact(dt.Rows[j]["BonusDate"].ToString(),"dd/MM/yyyy", null))
                        {
                            amount += Convert.ToDouble(dt.Rows[j]["DailyBonus"]);
                            j++;

                        }

                        if (amount < 1)
                        {
                            continue;
                        }
                        else
                        {
                            DataRow row;
                            row = newTable.NewRow();
                            row["BonusDate"] = i;
                            row["DailyBonus"] = amount;
                            newTable.Rows.Add(row);

                        }

                    }
                    GridDailyBonusGenerate.DataSource = newTable;
                    GridDailyBonusGenerate.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)
                {

                    //throw;
                }
            }
            else if (userAccount.historyOf == 2)
            {
                try
                {
                    var j = 0;
                    DataTable dt = userAccount.getTotalMatchingCommissionListbyDateRange(fromDateTextBox.Text, toDateTextBox.Text);

                    DataTable newTable = new DataTable();
                    DataColumn column;
                    column = newTable.Columns.Add();
                    column.ColumnName = "TransectionDate";
                    column.DataType = typeof(DateTime);

                    column = newTable.Columns.Add();
                    column.ColumnName = "Amount";
                    column.DataType = typeof(string);
                    DateTime StartDate = DateTime.ParseExact(fromDateTextBox.Text, "dd/MM/yyyy", null); ; ;
                    DateTime EndDate = DateTime.ParseExact(toDateTextBox.Text, "dd/MM/yyyy", null); ;

                    for (var i = StartDate; i <= EndDate; i = i.AddDays(1))
                    {

                        double amount = 0;
                        while (j < dt.Rows.Count && i == DateTime.ParseExact(dt.Rows[j]["TransectionDate"].ToString(), "dd/MM/yyyy", null))
                        {
                            amount += Convert.ToDouble(dt.Rows[j]["Amount"]);
                            j++;

                        }

                        if (amount < 1)
                        {
                            continue;
                        }
                        else
                        {
                            DataRow row;
                            row = newTable.NewRow();
                            row["TransectionDate"] = i;
                            row["Amount"] = amount;
                            newTable.Rows.Add(row);

                        }

                    }
                    GridCommision.DataSource = newTable;
                    GridCommision.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)
                {

                    //throw;

                }

            }
            else
            {
                msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Select a list!!!"; msgDetailLabel.Text = "";
            }
        }
        protected void btnPurches_Click(object sender, EventArgs e)
        {
            try
            {

                UserAccountBLL userAccount = new UserAccountBLL();
                StakeInfoBLL stakeInfo = new StakeInfoBLL();
                UserBLL user = new UserBLL();
                if (user.varifypin((string)LumexSessionManager.Get("ActiveUserId"), txtbxUserPintoPurches.Text))
                {
                    DataTable dt = userAccount.getAccountSummaryById((string) LumexSessionManager.Get("ActiveUserId"));
                    Decimal WalletAmount = 0;
                    string totalcount = "";
                    if (ddlPaymentBy.SelectedValue == "1")
                    {
                        WalletAmount = Convert.ToDecimal(dt.Rows[0]["Income"].ToString());
                    }
                    else if (ddlPaymentBy.SelectedValue == "2")
                    {
                        WalletAmount = Convert.ToDecimal(dt.Rows[0]["FxFund"].ToString());
                    }
                    if (Convert.ToDecimal(lblTotalPrice.Text) <= WalletAmount)
                    {
                        ///NEW///

                        StakeInfoBLL stake = new StakeInfoBLL();
                        int TotalPin = Convert.ToInt16(txtbxNoStake.Text);
                        DataTable dtstake = new DataTable();
                        DataRow dr = null;
                        dtstake.Columns.Add(new DataColumn("StakeId"));
                        dtstake.Columns.Add(new DataColumn("StakePin"));
                        dtstake.Columns.Add(new DataColumn("IsActive"));

                        for (int i = 0; i < TotalPin;)
                        {
                            string pinserial = GetSerialNumber();

                            dr = dtstake.NewRow();
                            if (!stake.CheckDuplicateKey(pinserial))
                            {
                                dr["StakeId"] = ddlstakeList.SelectedValue;
                                dr["StakePin"] = pinserial;
                                dr["IsActive"] = "Yes";
                                dtstake.Rows.Add(dr);
                                i++;
                            }
                        }
                        if (dtstake.Rows.Count == TotalPin && TotalPin > 0)
                        {
                            bool status = stake.SaveGeneratedPin(dtstake);

                            if (status)
                            {
                                dt = stakeInfo.updateKeyWhenPurchase(lblQuntity.Text, lblUnitPrice.Text,
                                    ddlstakeList.SelectedValue, ddlPaymentBy.SelectedValue);
                                if (dt.Rows.Count > 0)
                                {
                                    totalcount = dt.Rows[0][0].ToString();
                                }
                                string message = " <span class='actionTopic'>" + totalcount +
                                                 "KEY purchase Successfully. Thanks" + "</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { window.location = \"/a/stake/stakekeymanage.aspx\"; }; SuccessAlert(\"" +
                                    "Process Success" + "\", \"" + message + "\",callbackOk);");
                                getStakeKeyList();
                            }
                        }
                    }
                    else
                    {
                        string message = " <span class='actionTopic'>" +
                                         "Sorry you don't have sufficent Amount to purchase KEY. Thanks" + "</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { window.location = \"/a/initialdata/stakekeymanage.aspx\"; }; WarningAlert(\"" +
                            "Process Failed" + "\", \"" + message + "\", \"\");");
                    }
                }
                else
                {
                    string message = " <span class='actionTopic'>" +"Sorry Your PIN is not Correct. Input the correct one Thanks" + "</span>.";
                    MyAlertBox(
                        "var callbackOk = function () { window.location = \"/a/initialdata/stakekeymanage.aspx\"; }; WarningAlert(\"" +
                        "Process Failed" + "\", \"" + message + "\", \"\");");

                }
            }
            catch (Exception)
            {

                //throw;
            }
        }
        private void ReceivePaymentWhenActive()
        {
            StakeInfoBLL stakeInfo = new StakeInfoBLL();
            UserAccountBLL UserAccount = new UserAccountBLL();
            DataTable dt = new DataTable();
            dt = stakeInfo.GetStakeInfoById(ddlStakeList.SelectedValue);

            UserAccount.InsertReceivePaymentWhenActive((string)LumexSessionManager.Get("ActiveUserId"), txtbxReferId.Text.Trim(), dt.Rows[0]["Commission"].ToString());
        }
        private void getallUserAcountSummary()
        {
            try
            {
                UserAccountBLL accountBll = new UserAccountBLL();
                DataTable dt = accountBll.getAccountSummaryAllUser();
                GridViewIncomeSamary.DataSource = dt;
                GridViewIncomeSamary.DataBind();

            }
            catch (Exception)
            {

               // throw;
            }
            if (GridViewBlanceSheet.Rows.Count > 0)
            {
                // generateButton.Visible = true;
                GridViewBlanceSheet.UseAccessibleHeader = true;
                GridViewBlanceSheet.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            if (GridViewIncomeSamary.Rows.Count > 0)
            {
                // generateButton.Visible = true;
                GridViewIncomeSamary.UseAccessibleHeader = true;
                GridViewIncomeSamary.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
        }
        private void getmyAccountSummary(string UserId)
        {
            try
            {
                UserAccountBLL userAccount = new UserAccountBLL();
                DataTable dt = userAccount.getAccountSummaryById(UserId);
                if (dt.Rows.Count > 0)
                {
                    lvlIncome.Text = dt.Rows[0]["Income"].ToString();
                    lvlDeposit.Text =  dt.Rows[0]["Deposit"].ToString();
                    lvlCommision.Text =  dt.Rows[0]["Commission"].ToString();
                    lvlFund.Text = dt.Rows[0]["FxFund"].ToString();
                    if (Convert.ToDecimal(dt.Rows[0]["Deposit"].ToString()) > 0)
                    {
                        btnDeposit.Visible = true;
                    }
                    if (Convert.ToDecimal(dt.Rows[0]["Commission"].ToString()) > 0)
                    {
                        btnCommissionTransfer.Visible = true;

                    }
                    //if (Convert.ToDecimal(dt.Rows[0]["FxFund"].ToString()) > 0)
                    //{
                    //    btnFxFundTransfer.Visible = true;

                    //}
                }
                else
                {

                    lvlIncome.Text = "0";
                    lvlDeposit.Text = "0";
                    lvlCommision.Text = "0";
                    lvlFund.Text = "0";
                }
            }
            catch (Exception)
            {

                // throw;
            }
        }
        private void GetUserPlacementInfoById(string UserId)
        {
            try
            {
                UserAccountBLL userAccount = new UserAccountBLL();
                DataTable dt = userAccount.GetUserPlacementInfoById(UserId);
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["StakeId"].ToString() == "")
                    {
                        txtbxPlacementId.Text = dt.Rows[0]["PleacementId"].ToString();
                        txtbxReferId.Text = dt.Rows[0]["RefferId"].ToString();
                        ddlPosition.SelectedValue = dt.Rows[0]["PlacePosition"].ToString();

                        UserBLL userBll = new UserBLL();
                        dt = userBll.GetUserInfoById(txtbxReferId.Text);
                        if (dt.Rows.Count > 0)
                        {
                            hdnfldRefActive.Value = dt.Rows[0]["IsActive"].ToString();
                        }
                    }
                    else
                    {
                        txtbxStakeKey.Enabled = false;
                        btnActivation.Enabled = false;
                        string message = " <span class='actionTopic'> Your Account is Already Activated successfully. Thanks" + "</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { window.location = \"/a/initialdata/initialDataElement.aspx\"; }; SuccessAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", \"\");");

                    }
                }
                else
                {
                    // To do job
                }

            }
            catch (Exception)
            {

                //throw;
            }
        }
        protected void ViewButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlStatus.SelectedValue == "P")
                {
                    GridViewWithdrawRequest.Columns[6].Visible = false;
                    GridViewWithdrawRequest.Columns[7].Visible = false;
                }
                else if (ddlStatus.SelectedValue == "R")
                {
                   // GridViewWithdrawRequest.Columns[5].Visible = false;
                    GridViewWithdrawRequest.Columns[7].Visible = false;
                    GridViewWithdrawRequest.Columns[10].Visible = false;
                    GridViewWithdrawRequest.Columns[11].Visible = false;

                }
                else if (ddlStatus.SelectedValue == "A")
                {
                   // GridViewWithdrawRequest.Columns[5].Visible = false;
                    GridViewWithdrawRequest.Columns[6].Visible = false;
                    GridViewWithdrawRequest.Columns[10].Visible = false;
                    GridViewWithdrawRequest.Columns[11].Visible = false;
                }
                UserAccountBLL userAccount = new UserAccountBLL();
                DataTable dt = userAccount.getWithdrawRequestList(LumexLibraryManager.ParseAppDate(fromDateTextBox.Text), LumexLibraryManager.ParseAppDate(toDateTextBox.Text), ddlStatus.SelectedValue);

                GridViewWithdrawRequest.DataSource = dt;
                GridViewWithdrawRequest.DataBind();
                if (GridViewWithdrawRequest.Rows.Count > 0)
                {
                    // generateButton.Visible = true;
                    GridViewWithdrawRequest.UseAccessibleHeader = true;
                    GridViewWithdrawRequest.HeaderRow.TableSection = TableRowSection.TableHeader;
                }

            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                MyAlertBox("MyOverlayStop();");
            }
        }
        public void btnRequestSend_Click(object sender, EventArgs e)
        {
            UserAccountBLL account = new UserAccountBLL();
            UserBLL userBll = new UserBLL();
            account.Type = ddlType.SelectedValue;
            account.BankAccountNo = ddlPaymentMethod.SelectedItem.Text;
            account.TransferTo = txtbxTransferTo.Text.Trim();
            account.SwiftCode = ddlPaymentMethod.SelectedValue;
            account.Pin = txtbxTransferPin.Text.Trim();
            account.TransferNote = txtbxTransferNote.Text.Trim();
            account.Amount = txtbxAmount.Text.Trim();
            account.transfarType = ddlType.SelectedValue;
            string message = "";
            if (account.checkUserIncomeAmounttoActin(30, (string)LumexSessionManager.Get("ActiveUserId")))
            {
                if (userBll.varifypin((string)LumexSessionManager.Get("ActiveUserId"), account.Pin))
                {
                    if (ddlType.SelectedValue == "1")
                    {
                        if (Convert.ToDecimal(account.Amount) < 4000)
                        {
                            if (account.TransferTo != (string)LumexSessionManager.Get("ActiveUserId") && userBll.CheckDuplicateUser(account.TransferTo))
                            {
                                account.Status = "A";
                                bool status = account.RequestToTransfer();
                                if (status)
                                {
                                    account.updateUserAccountforTransfer();
                                    account.updateWithdrawRequest(account.transfarId, "A");
                                    message =
                                        "Payment <span class='actionTopic'>Fund Transfer</span> Successfully Done. Thanks.";
                                    MyAlertBox(
                                        "var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/withdraw.aspx\"; }; SuccessAlert(\"" +
                                        "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                                }

                            }
                            else
                            {
                                message =
                                    "Please Give   <span class='actionTopic'>Correct User Info </span> to Transfer.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/withdraw.aspx\"; }; WarningAlert(\"" +
                                    "Warning!!" + "\", \"" + message + "\", \"\");");
                            }
                        }
                        else
                        {
                            account.Status = "P";
                            bool status = account.RequestToTransfer();
                            if (status)
                            {
                                account.updateUserAccountforTransfer();
                                message =
                                    "Payment <span class='actionTopic'>Transfer Request</span> Successfully Done. Thanks.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/withdraw.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                            }
                        }

                    }
                    else if (ddlType.SelectedValue == "0")
                    {
                        if (Convert.ToDecimal(account.Amount) >= 30)
                        {

                            account.Status = "P";
                            bool status = account.RequestToTransfer();
                            if (status)
                            {
                                account.updateUserAccountforTransfer();
                                message =
                                    "Payment <span class='actionTopic'>Transfer Request</span> Successfully Done. Thanks.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/withdraw.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                            }
                        }
                        else
                        {
                            message = "You can not transfer less than <span class='actionTopic'>$30</span>, Thanks.";
                            MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/moneygerate.aspx\"; }; SuccessAlert(\"" + "Warning note!!" + "\", \"" + message + "\", \"\");");

                        }

                    }

                }
                else
                {
                    message = "Please Enter Your Correct <span class='actionTopic'>Pin</span> to Transfer.";
                    MyAlertBox(
                        "var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/withdraw.aspx\"; }; WarningAlert(\"" +
                        "Warning!!" + "\", \"" + message + "\", \"\");");
                }
            }

            else
            {
                message = "You have no sufficient  <span class='actionTopic'>Amount</span> to Transfer.";
                MyAlertBox(
                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/a/account/withdraw.aspx\"; }; WarningAlert(\"" +
                    "Warning!!" + "\", \"" + message + "\", \"\");");

            }
        }