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; } }
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; } }