Exemplo n.º 1
0
        public string acreditarDebitar(CreditoDebitoModels creditoDebito)
        {
            String format = "MM/dd/yyyy";
            String fecha  = creditoDebito.fecha.ToString(format);

            int error = bDservice.Upd_New_DelUnValorQry_SLID("insert into dbo.CREDITODEBITO (id_cuenta,descripcion,fecha,monto,tipo) values (" + creditoDebito.cuenta.id_cuenta +
                                                             ",'" + creditoDebito.descripcion + "','" + fecha + "'," + creditoDebito.monto + "," + creditoDebito.tipo + ")");

            if (error == 0)
            {
                return("No existe cuenta");
            }

            double saldo = getSaldoCuenta(creditoDebito.cuenta.id_cuenta);

            if (creditoDebito.tipo == 1)
            {
                saldo += creditoDebito.monto;
            }
            else
            {
                if (!tieneFondos(saldo, creditoDebito.monto))
                {
                    return("No tiene suficientes fondos");
                }
                saldo -= creditoDebito.monto;
            }
            bDservice.Upd_New_DelUnValorQry("update dbo.CUENTA set saldo = " + saldo + " where id_cuenta = " + creditoDebito.cuenta.id_cuenta);
            return("");
        }
Exemplo n.º 2
0
        public int crearNuevoUsuario(UsuarioModels user)
        {
            String campos  = "INSERT INTO dbo.USUARIO(id_usuario,usuario,correo,contraseña,nombre,apellido)";
            String valores = string.Format("VALUES({0},'{1}','{2}','{3}','{4}','{5}')", user.id_usuario, user.usuario, user.correo, user.contrasenia, user.nombre, user.apellido);
            String query   = campos + valores;

            return(serviceBD.Upd_New_DelUnValorQry_SLID(query));
        }