Example #1
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;
            }
        }