Exemple #1
0
        //INICIO CARD COMPRAR
        protected void BuySend_Click(object sender, EventArgs e)
        {
            try
            {
                decimal userInputBuy = Convert.ToDecimal(InputBuy.Text);

                PIM4LINQDataContext db = new PIM4LINQDataContext();

                var userData = (from f in db.Users
                                where f.IdUser.Equals(Convert.ToString(LoggedUser.idUserLogged))
                                select f).Single();

                userData.dogeValue = userData.dogeValue + userInputBuy;

                db.SubmitChanges();

                Response.Write(txtCode.Text = "Compra realizada com sucesso!");
                txtCode.Focus();
                txtCode.Visible = true;
                containerPopUp.Style.Add("Visibility", "Visible");
                return;
            }
            catch (Exception ex)
            {
                Response.Write(txtCode.Text = "Erro ao carregar os dados: " + ex.Message);
                txtCode.Focus();
                txtCode.Visible = true;
                containerPopUp.Style.Add("Visibility", "Visible");
                return;
            }
        }
Exemple #2
0
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            string pass1 = txtPass.Text;
            string pass2 = txtPassConfirm.Text;

            if (string.IsNullOrEmpty(txtUser.Text) ||
                string.IsNullOrEmpty(txtEmail.Text) ||
                string.IsNullOrEmpty(txtDocument.Text) ||
                string.IsNullOrEmpty(txtBirthday.Text) ||
                string.IsNullOrEmpty(txtPass.Text) ||
                string.IsNullOrEmpty(txtPassConfirm.Text))
            {
                Response.Write(txtCode.Text = "Insira todos os dados para continuar!");
                txtCode.Focus();
                txtCode.Visible = true;
                containerPopUp.Style.Add("Visibility", "Visible");
                return;
            }

            if (pass1 == pass2 && !string.IsNullOrEmpty(txtPass.Text))
            {
                //iniciando o data context

                PIM4LINQDataContext db = new PIM4LINQDataContext();
                User user = new User();
                user.Username = txtUser.Text;
                user.Email    = txtEmail.Text;
                user.Birthday = txtBirthday.Text;
                user.Password = txtPass.Text;
                user.Document = txtDocument.Text;

                //Instancia as carteiras garantindo que elas estejam vazias
                user.btcValue  = Convert.ToDecimal(0.00000000);
                user.ethValue  = Convert.ToDecimal(0.00000000);
                user.dogeValue = Convert.ToDecimal(0.00000000);
                user.usdtValue = Convert.ToDecimal(0.00000000);
                user.xrpValue  = Convert.ToDecimal(0.00000000);

                db.Users.InsertOnSubmit(user);
                db.SubmitChanges();


                Response.Write(txtCode.Text = "Usuário cadastrado com sucesso!");
                txtCode.Focus();
                txtCode.BackColor = Color.LightPink;
                txtCode.Visible   = true;
                containerPopUp.Style.Add("Visibility", "Visible");
                return;
            }
            if (pass1 != pass2)
            {
                Response.Write(txtCode.Text = "As senhas não coincidem!");
                txtCode.Focus();
                txtCode.Visible = true;
                containerPopUp.Style.Add("Visibility", "Visible");
                return;
            }
        }
Exemple #3
0
        //FIM CARD COMPRAR

        //INICIO CARD VENDER

        protected void SellSend_Click(object sender, EventArgs e)
        {
            decimal userInputSell = Convert.ToDecimal(InputSell.Text);

            try
            {
                PIM4LINQDataContext db = new PIM4LINQDataContext();

                var userData = (from f in db.Users
                                where f.IdUser.Equals(Convert.ToString(LoggedUser.idUserLogged))
                                select f).Single();

                if (userInputSell <= userData.dogeValue)
                {
                    userData.dogeValue = userData.dogeValue - userInputSell;

                    db.SubmitChanges();

                    Response.Write(txtCode.Text = "Venda realizada com sucesso!");
                    txtCode.Focus();
                    txtCode.Visible = true;
                    containerPopUp.Style.Add("Visibility", "Visible");
                    return;
                }
                else
                {
                    Response.Write(txtCode.Text = "Fundos insuficientes para venda");
                    txtCode.Focus();
                    txtCode.Visible = true;
                    containerPopUp.Style.Add("Visibility", "Visible");
                    return;
                }
            }
            catch (Exception ex)
            {
                Response.Write(txtCode.Text = "Erro ao carregar os dados: " + ex.Message);
                txtCode.Focus();
                txtCode.Visible = true;
                containerPopUp.Style.Add("Visibility", "Visible");
                return;
            }
        }