Exemplo n.º 1
0
    public void updatescore(string val)
    {
        int    betamount = Convert.ToInt32(Session["bet"].ToString());
        string username  = Session["username"].ToString();

        using (var context = new Testdata1Entities())
        {
            var newa = from u in context.accountdetails
                       where u.user_name == username
                       select u;
            var newb = newa.FirstOrDefault();
            int bal  = Convert.ToInt32(newb.balance);
            if (val == "dealer")
            {
                bal = bal - 0;
            }
            else if (val == "player")
            {
                bal = bal + 2 * betamount;
            }
            else
            {
                bal = bal + betamount;
            }
            string final = Convert.ToString(bal);
            lbl_cashavail.Text      = String.Format("Wallet - $ {0}", final);
            lbl_cashavail.ForeColor = System.Drawing.Color.Red;
            newb.balance            = final;
            context.SaveChanges();

            enable("play");
        }
    }
    protected void Registerbtn_Click(object sender, EventArgs e)
    {
        string username = Usertxt.Text;
        string pwd1     = Pwd1txt.Text;
        string pwd2     = Pwd2txt.Text;

        if (username != "")
        {
            if (pwd1 != pwd2 || pwd1 == "" || pwd2 == "")
            {
                ErrMsg.Visible   = true;
                ErrMsg.ForeColor = Color.Red;
                ErrMsg.Text      = "Password Mismatch or No password. Try again";
                return;
            }
            using (var context = new Testdata1Entities())
            {
                var check = from u in context.users
                            where u.user_name == username
                            select u;
                var b = check.FirstOrDefault();
                if (b == null)
                {
                    #region Insert UserName
                    user a = new user();
                    a.user_name = username;
                    a.password  = pwd1;
                    context.users.Add(a);
                    context.SaveChanges();
                    Regislabel.Text      = "Registration Completed succesfully";
                    Regislabel.ForeColor = Color.Green;
                    Response.Redirect("~/Login.aspx");
                    #endregion Insert UserName
                }
                else
                {
                    #region UserName already exists
                    ErrMsg.Visible   = true;
                    ErrMsg.ForeColor = Color.Red;
                    ErrMsg.Text      = "User Name already exists.";
                    return;

                    #endregion UserName already exists
                }
            }
            ErrMsg.Visible = false;
        }
        else
        {
            #region Invalid Password
            ErrMsg.Visible   = true;
            ErrMsg.ForeColor = Color.Red;
            ErrMsg.Text      = "Please enter a valid Password";
            #endregion Invalid Password
        }
    }
Exemplo n.º 3
0
    public void pontstable(string val, string val1)
    {
        string username = Session["username"].ToString();

        using (var context = new Testdata1Entities())
        {
            var prof = new profile();
            prof.user_name = username;
            prof.played    = true;
            if (val == "dealer")
            {
                prof.won       = false;
                prof.lost      = true;
                prof.blackjack = false;
                prof.push      = false;
            }
            else if (val == "player")
            {
                prof.won  = true;
                prof.lost = true;
                if (val1 == "blackjack")
                {
                    prof.blackjack = true;
                }
                else
                {
                    prof.blackjack = false;
                }
                prof.push = false;
            }
            else if (val == "push")
            {
                prof.won       = false;
                prof.lost      = false;
                prof.blackjack = false;
                prof.push      = true;
            }
            context.profiles.Add(prof);
            context.SaveChanges();
        }
        using (var context1 = new Testdata1Entities())
        {
            user_scores user = new user_scores();
            user.user_name = username;
            user.score     = Convert.ToInt32(hdn_point_player.Value.ToString());
            context1.user_scores.Add(user);
            context1.SaveChanges();
        }
    }
Exemplo n.º 4
0
 protected void btn_bet_Click(object sender, EventArgs e)
 {
     if (!txt_bet.Visible)
     {
         txt_bet.Visible = true;
         txt_bet.Focus();
     }
     else
     {
         string username = Session["username"].ToString(); // "Mukesh"; //"Mukesh"; //
         if (txt_bet.Text == "" || txt_bet.Text == "0" || txt_bet.Text.Contains("-") || txt_bet.Text.Contains("."))
         {
             lbl_caution.Text      = "Please enter a valid amount to bet";
             lbl_caution.BackColor = System.Drawing.Color.Red;
             lbl_caution.Font.Bold = true;
         }
         else
         {
             lbl_caution.Text = "";
             int amount = Convert.ToInt32(txt_bet.Text);
             Session["bet"] = txt_bet.Text;
             using (var context = new Testdata1Entities())
             {
                 var a = from u in context.accountdetails
                         where u.user_name == username
                         select u;
                 var b          = a.FirstOrDefault();
                 int cashinhand = Convert.ToInt32(b.balance);
                 int newbet     = cashinhand - amount;
                 if (newbet >= 0)
                 {
                     b.balance = Convert.ToString(newbet);
                     context.SaveChanges();
                     lbl_raisebet.Text  = "Bet $ " + amount;
                     lbl_cashavail.Text = String.Format("Wallet - $ {0}", newbet);
                     enable("bet");
                 }
                 else
                 {
                     lbl_caution.Text      = String.Format("Sorry, you cant bet above your wallet limit. Your bet limit is $ {0}", b.balance);
                     lbl_caution.BackColor = System.Drawing.Color.Red;
                 }
             }
         }
     }
 }
    protected void changepwdbtn_Click(object sender, EventArgs e)
    {
        string oldpwd   = oldpwdtxt.Text;
        string newpwd   = newpwdtxt.Text;
        string renewpwd = repwdtxt.Text;
        string username = Session["username"].ToString();

        if (oldpwd == "" || newpwd == "" || renewpwd == "")
        {
            msglbl.Text      = "Password cannot be empty";
            msglbl.BackColor = System.Drawing.Color.Red;
            return;
        }
        using (var context = new Testdata1Entities())
        {
            var a = from u in context.users
                    where u.password == oldpwd && u.user_name == username
                    select u;
            var b = a.FirstOrDefault();
            if (b != null)
            {
                if (newpwd == renewpwd)
                {
                    b.password = newpwd;
                    context.SaveChanges();
                    msglbl.Text      = "Your password has been changed.";
                    msglbl.BackColor = System.Drawing.Color.Red;
                }
                else
                {
                    msglbl.Text      = "Password mismatch.";
                    msglbl.BackColor = System.Drawing.Color.Red;
                }
            }
            else if (b == null)
            {
                msglbl.Text      = "Incorrect existing password.";
                msglbl.BackColor = System.Drawing.Color.Red;
            }
        }
    }
Exemplo n.º 6
0
    protected void Proceedbtn_Click(object sender, EventArgs e)
    {
        #region Error-Validation
        if (cardnotxt.Text.Length != 16)
        {
            cautionlbl.Text      = "Invalid card number.Please enter the 16 digit card number again.";
            cautionlbl.ForeColor = Color.Red;
            return;
        }
        if (cvvtxt.Text.Length != 3)
        {
            cautionlbl.Text      = "Invalid cvv number.Please enter the 3 digit cvv number again.";
            cautionlbl.ForeColor = Color.Red;
            return;
        }
        if (nametxt.Text.Length == 0)
        {
            cautionlbl.Text      = "Please enter a valid name.";
            cautionlbl.ForeColor = Color.Red;
            return;
        }

        char[] cardno = cardnotxt.Text.ToCharArray();
        int    length = cardno.Length;
        for (int i = 0; i < length; i++)
        {
            if (!char.IsDigit(cardno[i]))
            {
                cautionlbl.Text      = "Only number is allowed in card number.";
                cautionlbl.ForeColor = Color.Red;
                return;
            }
        }
        #endregion

        #region logica-part
        int    amount   = Convert.ToInt32(Session["amount"].ToString());
        string username = Session["username"].ToString();
        using (var context = new Testdata1Entities())
        {
            string cash = "";
            var    a    = from u in context.accountdetails
                          where u.user_name == username
                          select u;
            var b = a.FirstOrDefault();
            if (b != null)
            {
                cash      = (Convert.ToInt32(b.balance) + amount).ToString();
                b.balance = cash;

                context.SaveChanges();
                Session["amount"] = cash;
            }
            else
            {
                cash = amount.ToString();
                accountdetail d = new accountdetail();
                d.balance   = cash;
                d.user_name = username;
                context.accountdetails.Add(d);
                context.SaveChanges();
            }
        }
        Session["redirect"] = "success";
        Response.Write("<script>");
        Response.Write("window.open('UserProfile.aspx','_parent')");
        Response.Write("</script>");
        #endregion
    }