示例#1
0
        public TipoCuentaBancaria buscarTipoCuenta(int Codigo)
        {
            SqlConnection      conString = new SqlConnection(@"Data Source=DESKTOP-6DRGPE6;Initial Catalog=ParcialSAP;Integrated Security=True");
            TipoCuentaBancaria tc        = new TipoCuentaBancaria();

            try
            {
                conString.Open();
                SqlCommand command = new SqlCommand();
                command.Connection = conString;
                command.Parameters.AddWithValue("Codigo", Codigo);
                command.CommandText = "select nombre from TipoCuentaBancaria where Codigo = @Codigo";
                command.CommandType = System.Data.CommandType.Text;
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    tc.Codigo = Codigo;
                    tc.Nombre = reader["Nombre"].ToString();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                conString.Close();
            }
            return(tc);
        }
示例#2
0
        //public void registrarDeposito(CuentaBancaria c)
        //{
        //    SqlConnection conString = new SqlConnection(@"Data Source=DESKTOP-6DRGPE6;Initial Catalog=ParcialSAP;Integrated Security=True");
        //    try
        //    {
        //        CuentaBancaria c_original = new CuentaBancaria();
        //        c_original = traerCuenta(c.NumeroCuenta);
        //        c.Saldo = c_original.saldo + c.saldo;
        //        conString.Open();
        //        SqlTransaction transaction;
        //        transaction = conString.BeginTransaction();
        //        SqlCommand command = new SqlCommand();
        //        command.Connection = conString;
        //        command.Parameters.AddWithValue("nro_cuenta", c.nro_cuenta);
        //        command.Parameters.AddWithValue("saldo", c.saldo);
        //        command.CommandText = "update Cuenta set saldo = @saldo where nro_cuenta = @nro_cuenta";
        //        command.CommandType = System.Data.CommandType.Text;
        //        command.Transaction = transaction;
        //        command.ExecuteNonQuery();
        //        transaction.Commit();
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e.Message);
        //    }
        //    finally
        //    {
        //        conString.Close();
        //    }
        //}
        //public void registrarExtraccion(CuentaBancaria c)
        //{
        //    SqlConnection conString = new SqlConnection(@"Data Source=DESKTOP-6DRGPE6;Initial Catalog=ParcialSAP;Integrated Security=True");
        //    try
        //    {
        //        CuentaBancaria c_original = new CuentaBancaria();
        //        c_original = traerCuenta(c.nro_cuenta);

        //        if (c.tipo.nro_tipo == 1)
        //        {
        //            if (c_original.saldo - c.saldo >= 0)
        //            {
        //                c.saldo = c_original.saldo - c.saldo;
        //            }
        //            else
        //            {
        //                c.saldo = c_original.saldo;
        //            }
        //        }
        //        else
        //        {
        //            c.saldo = c_original.saldo - c.saldo;
        //        }
        //        conString.Open();
        //        SqlTransaction transaction;
        //        transaction = conString.BeginTransaction();
        //        SqlCommand command = new SqlCommand();
        //        command.Connection = conString;
        //        command.Parameters.AddWithValue("nro_cuenta", c.nro_cuenta);
        //        command.Parameters.AddWithValue("saldo", c.saldo);
        //        command.CommandText = "update Cuenta set saldo = @saldo where nro_cuenta = @nro_cuenta";
        //        command.CommandType = System.Data.CommandType.Text;
        //        command.Transaction = transaction;
        //        command.ExecuteNonQuery();
        //        transaction.Commit();
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e.Message);
        //    }
        //    finally
        //    {
        //        conString.Close();
        //    }
        //}
        public List <TipoCuentaBancaria> buscarTipos()
        {
            SqlConnection             conString = new SqlConnection(@"Data Source=DESKTOP-6DRGPE6;Initial Catalog=ParcialSAP;Integrated Security=True");
            List <TipoCuentaBancaria> tc        = new List <TipoCuentaBancaria>();

            try
            {
                conString.Open();
                SqlCommand command = new SqlCommand();
                command.Connection  = conString;
                command.CommandText = "select * from TipoCuentaBancaria";
                command.CommandType = System.Data.CommandType.Text;
                var reader = command.ExecuteReader();
                while (reader.Read())
                {
                    TipoCuentaBancaria t = new TipoCuentaBancaria();
                    t.Codigo = Int32.Parse(reader["Codigo"].ToString());
                    t.Nombre = reader["Nombre"].ToString();
                    tc.Add(t);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                conString.Close();
            }
            return(tc);
        }
示例#3
0
        public void Transferencia()
        {
            Boolean            resultado = true;
            double             monto;
            CuentaBancaria     cuentabancariatest2 = new CuentaBancaria();
            CuentaBancaria     cuentabancariatest1 = new CuentaBancaria();
            CuentaBLL          cuentabll           = new CuentaBLL();
            TipoCuentaBancaria tipo = new TipoCuentaBancaria();



            tipo.Codigo = 1;
            monto       = 100;
            cuentabancariatest1.NumeroCuenta       = 1;
            cuentabancariatest1.TipoCuentaBancaria = tipo;
            cuentabancariatest1.Saldo              = 100;
            cuentabancariatest1.Propietario        = "Test1";
            cuentabancariatest2.NumeroCuenta       = 2;
            cuentabancariatest2.TipoCuentaBancaria = tipo;
            cuentabancariatest2.Saldo              = 100;
            cuentabancariatest2.Propietario        = "Test2";


            Assert.AreEqual(cuentabll.Transferencia(cuentabancariatest1, cuentabancariatest2, monto), resultado);
        }
示例#4
0
        public TipoCuentaBancaria buscarTipoCuenta(int nro_tipo)
        {
            TipoCuentaBancaria tc = new TipoCuentaBancaria();

            try
            {
                CuentaDAL cuentaDAL = new CuentaDAL();
                tc = cuentaDAL.buscarTipoCuenta(nro_tipo);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(tc);
        }
示例#5
0
        public void Retiro()
        {
            Boolean            resultado = true;
            double             monto;
            CuentaBancaria     cuentabancariatest = new CuentaBancaria();
            CuentaBLL          cuentabll          = new CuentaBLL();
            TipoCuentaBancaria tipo = new TipoCuentaBancaria();



            tipo.Codigo = 1;
            monto       = 100;
            cuentabancariatest.NumeroCuenta       = 100;
            cuentabancariatest.TipoCuentaBancaria = tipo;
            cuentabancariatest.Saldo       = 100;
            cuentabancariatest.Propietario = "Test";


            Assert.AreEqual(cuentabll.Retiro(cuentabancariatest, cuentabancariatest.Saldo), resultado);
        }