示例#1
0
        private bool validarLogin()
        {
            string     query   = "SELECT * from login as L where L.login = '******' AND L.senha = '" + txtSenha.Text + "'";
            ClsConexao conexao = new ClsConexao();

            try
            {
                conexao.conectar();
                SqlCommand cmd = new SqlCommand(query, conexao.conexao);

                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    Data.saldo    = double.Parse(dr["saldo"].ToString());
                    Data.idLogado = Int16.Parse(dr["Id"].ToString());
                    return(true);
                }
                else
                {
                    MessageBox.Show("Usuario ou senha inválidos");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            finally
            {
                conexao.desconectar();
            }
        }
示例#2
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            Data.saldo = Data.saldo + valorDeposito;
            Banco      banco   = new Banco();
            string     update  = "UPDATE login SET saldo =" + Data.saldo + " WHERE Id =" + Data.idLogado + "";
            ClsConexao conexao = new ClsConexao();

            conexao.conectar();

            SqlCommand cmd = new SqlCommand(update, conexao.conexao);

            cmd.ExecuteReader(CommandBehavior.SingleRow);
            conexao.desconectar();
            this.Hide();
            banco.ShowDialog();
            this.Close();

            /*string update = "UPDATE login SET saldo = '" + Data.saldo + "' WHERE Id = '" + Data.idLogado + "'";
             * ClsConexao conexao = new ClsConexao();
             * conexao.conectar();
             *
             * SqlCommand cmd = new SqlCommand(update, conexao.conexao);
             * cmd.ExecuteReader();
             * MessageBox.Show("Saque realizado com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Question);
             * concluido = true;
             * btnSacar.Enabled = false;
             * btnFechar.Text = "Voltar";*/
        }
示例#3
0
        private void btnSacar_Click(object sender, EventArgs e)
        {
            if (concluido == false)
            {
                Data.saldo = Data.saldo - double.Parse(Data.valorDigitado2);
                string     update  = "UPDATE login SET saldo =" + Data.saldo + " WHERE Id =" + Data.idLogado + "";
                ClsConexao conexao = new ClsConexao();
                conexao.conectar();

                SqlCommand cmd = new SqlCommand(update, conexao.conexao);
                cmd.ExecuteReader(CommandBehavior.SingleRow);
                conexao.desconectar();

                /*string update = "update login set saldo=@saldo where id=@Id";
                 * ClsConexao conexao = new ClsConexao();
                 * conexao.conectar();
                 *
                 * SqlCommand cmd = new SqlCommand(update, conexao.conexao);
                 * cmd.Parameters.AddWithValue("@saldo", Convert.ToDecimal(label1.Text));
                 * cmd.Parameters.AddWithValue("@Id", Convert.ToInt32(label2.Text));
                 * cmd.ExecuteReader(CommandBehavior.SingleRow);
                 * conexao.desconectar();*/

                MessageBox.Show("Saque realizado com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Question);
                concluido        = true;
                btnSacar.Enabled = false;
                btnFechar.Text   = "Voltar";
            }

            /*    string query = "SELECT * from login as L where L.login = '******' AND L.senha = '" + txtSenha.Text + "'";
             * ClsConexao conexao = new ClsConexao();
             * try
             * {
             *  conexao.conectar();
             *  SqlCommand cmd = new SqlCommand(query, conexao.conexao);
             *
             *  SqlDataReader dr = cmd.ExecuteReader();
             *  if (dr.Read())
             *  {
             *      Data.saldo = double.Parse(dr["saldo"].ToString());
             *      Data.idLogado = Int16.Parse(dr["Id"].ToString());
             *      return true;*/
        }